1 (* P3SymBuild.def pass 3 symbol creation.
3 Copyright (C) 2001-2023 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
22 DEFINITION MODULE P3SymBuild ;
29 System : UNIX (GNU Modula-2)
30 Description: pass 3 symbol creation.
33 (* StartBuildDefinitionModule, *)
34 (* EndBuildDefinitionModule, *)
35 (* StartBuildImplementationModule, *)
36 (* EndBuildImplementationModule, *)
37 (* StartBuildProgramModule, *)
38 (* EndBuildProgramModule, *)
40 EXPORT QUALIFIED P3StartBuildDefModule,
42 P3StartBuildImpModule,
44 P3StartBuildProgModule,
46 StartBuildInnerModule,
48 CheckImportListOuterModule,
50 BuildProcedureHeading,
57 BuildOptArgInitializer ;
61 StartBuildDefinitionModule - Creates a definition module and starts
64 The Stack is expected:
69 +------------+ +-----------+
70 | NameStart | | NameStart |
71 |------------| |-----------|
75 PROCEDURE P3StartBuildDefModule ;
79 EndBuildDefinitionModule - Destroys the definition module scope and
80 checks for correct name.
82 The Stack is expected:
87 +------------+ +-----------+
89 |------------| |-----------|
90 | NameStart | | | <- Ptr
91 |------------| |-----------|
94 PROCEDURE P3EndBuildDefModule ;
98 StartBuildImplementationModule - Creates an implementation module and starts
101 The Stack is expected:
106 +------------+ +-----------+
107 | NameStart | | NameStart |
108 |------------| |-----------|
112 PROCEDURE P3StartBuildImpModule ;
116 EndBuildImplementationModule - Destroys the implementation module scope and
117 checks for correct name.
119 The Stack is expected:
124 +------------+ +-----------+
126 |------------| |-----------|
127 | NameStart | | | <- Ptr
128 |------------| |-----------|
131 PROCEDURE P3EndBuildImpModule ;
135 StartBuildProgramModule - Creates a program module and starts
138 The Stack is expected:
143 +------------+ +-----------+
144 | NameStart | | NameStart |
145 |------------| |-----------|
149 PROCEDURE P3StartBuildProgModule ;
153 EndBuildProgramModule - Destroys the program module scope and
154 checks for correct name.
156 The Stack is expected:
161 +------------+ +-----------+
163 |------------| |-----------|
164 | NameStart | | | <- Ptr
165 |------------| |-----------|
168 PROCEDURE P3EndBuildProgModule ;
172 CheckCanBeImported - checks to see that it is legal to import, Sym, from, ModSym.
175 PROCEDURE CheckCanBeImported (ModSym, Sym: CARDINAL) ;
179 StartBuildInnerModule - Creates an Inner module and starts
182 The Stack is expected:
187 +------------+ +-----------+
188 | NameStart | | NameStart |
189 |------------| |-----------|
193 PROCEDURE StartBuildInnerModule ;
197 EndBuildInnerModule - Destroys the Inner module scope and
198 checks for correct name.
200 The Stack is expected:
205 +------------+ +-----------+
207 |------------| |-----------|
208 | NameStart | | | <- Ptr
209 |------------| |-----------|
212 PROCEDURE EndBuildInnerModule ;
216 CheckImportListOuterModule - checks to see that all identifiers are
217 exported from the definition module.
219 The Stack is expected:
224 +------------+ +-----------+
226 |------------| |-----------|
228 |------------| |-----------|
232 |------------| |-----------|
234 |------------| |-----------|
235 | ImportTok | | Ident |
236 |------------| |-----------|
238 IMPORT Id1, .. Id# ; FROM Ident IMPORT Id1 .. Id# ;
244 All above stack discarded
247 PROCEDURE CheckImportListOuterModule ;
251 BuildProcedureHeading - Builds a procedure heading for the definition
254 Operation only performed if compiling a
268 PROCEDURE BuildProcedureHeading ;
272 StartBuildProcedure - Builds a Procedure.
281 +------------+ |------------|
283 |------------| |------------|
286 PROCEDURE StartBuildProcedure ;
290 EndBuildProcedure - Ends building a Procedure.
291 It checks the start procedure name matches the end
310 PROCEDURE EndBuildProcedure ;
314 BuildSubrange - Builds a Subrange type Symbol.
328 PROCEDURE BuildSubrange ;
332 BuildNulName - Pushes a NulKey onto the top of the stack.
344 PROCEDURE BuildNulName ;
348 BuildConst - builds a constant.
354 +------------+ +------------+
356 |------------+ |------------|
359 PROCEDURE BuildConst ;
363 BuildVarAtAddress - updates the symbol table entry of, variable sym, to be declared
372 | Expr | EType | <- Ptr
373 |--------------+ +--------------+
374 | name | SType | | name | SType |
375 |--------------+ |--------------|
378 PROCEDURE BuildVarAtAddress ;
382 BuildOptArgInitializer - assigns the constant value symbol, const, to be the
383 initial value of the optional parameter should it be
389 |------------| <- Ptr
392 PROCEDURE BuildOptArgInitializer ;