1 (* PCSymBuild.def pass C symbol creation.
3 Copyright (C) 2001-2024 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 PCSymBuild ;
27 System : UNIX (GNU Modula-2)
28 Description: provides scope mainstance for Pass C it also resolves
29 the import/export symbols and assigns types to constructors.
32 EXPORT QUALIFIED PCStartBuildDefModule,
34 PCStartBuildImpModule,
36 PCStartBuildProgModule,
38 PCStartBuildInnerModule,
39 PCEndBuildInnerModule,
40 PCBuildProcedureHeading,
41 PCStartBuildProcedure,
45 PCBuildImportOuterModule,
46 PCBuildImportInnerModule,
56 PushConstAttributeType,
57 PushConstAttributePairType,
58 PushConstructorCastType,
60 PushConstFunctionType,
67 StartBuildDefinitionModule - Creates a definition module and starts
70 The Stack is expected:
75 +------------+ +-----------+
76 | NameStart | | NameStart |
77 |------------| |-----------|
81 PROCEDURE PCStartBuildDefModule ;
85 EndBuildDefinitionModule - Destroys the definition module scope and
86 checks for correct name.
88 The Stack is expected:
93 +------------+ +-----------+
95 |------------| |-----------|
96 | NameStart | | | <- Ptr
97 |------------| |-----------|
100 PROCEDURE PCEndBuildDefModule ;
104 StartBuildImplementationModule - Creates an implementation module and starts
107 The Stack is expected:
112 +------------+ +-----------+
113 | NameStart | | NameStart |
114 |------------| |-----------|
118 PROCEDURE PCStartBuildImpModule ;
122 EndBuildImplementationModule - Destroys the implementation module scope and
123 checks for correct name.
125 The Stack is expected:
130 +------------+ +-----------+
132 |------------| |-----------|
133 | NameStart | | | <- Ptr
134 |------------| |-----------|
137 PROCEDURE PCEndBuildImpModule ;
141 StartBuildProgramModule - Creates a program module and starts
144 The Stack is expected:
149 +------------+ +-----------+
150 | NameStart | | NameStart |
151 |------------| |-----------|
155 PROCEDURE PCStartBuildProgModule ;
159 EndBuildProgramModule - Destroys the program module scope and
160 checks for correct name.
162 The Stack is expected:
167 +------------+ +-----------+
169 |------------| |-----------|
170 | NameStart | | | <- Ptr
171 |------------| |-----------|
174 PROCEDURE PCEndBuildProgModule ;
178 StartBuildInnerModule - Creates an Inner module and starts
181 The Stack is expected:
186 +------------+ +-----------+
187 | NameStart | | NameStart |
188 |------------| |-----------|
192 PROCEDURE PCStartBuildInnerModule ;
196 EndBuildInnermModule - Destroys the Inner module scope and
197 checks for correct name.
199 The Stack is expected:
204 +------------+ +-----------+
206 |------------| |-----------|
207 | NameStart | | | <- Ptr
208 |------------| |-----------|
211 PROCEDURE PCEndBuildInnerModule ;
215 BuildProcedureHeading - Builds a procedure heading for the definition
218 Operation only performed if compiling a
232 PROCEDURE PCBuildProcedureHeading ;
236 StartBuildProcedure - Builds a Procedure.
245 +------------+ |------------|
247 |------------| |------------|
250 PROCEDURE PCStartBuildProcedure ;
254 EndBuildProcedure - Ends building a Procedure.
255 It checks the start procedure name matches the end
274 PROCEDURE PCEndBuildProcedure ;
278 BuildImportOuterModule - Builds imported identifiers into an outer module
279 from a definition module.
281 The Stack is expected:
286 +------------+ +-----------+
288 |------------| |-----------|
290 |------------| |-----------|
294 |------------| |-----------|
296 |------------| |-----------|
297 | ImportTok | | Ident |
298 |------------| |-----------|
300 IMPORT Id1, .. Id# ; FROM Ident IMPORT Id1 .. Id# ;
305 All above stack discarded
308 PROCEDURE PCBuildImportOuterModule ;
312 BuildImportInnerModule - Builds imported identifiers into an inner module
313 from the last level of module.
315 The Stack is expected:
320 +------------+ +-----------+
322 |------------| |-----------|
324 |------------| |-----------|
328 |------------| |-----------|
330 |------------| |-----------|
331 | ImportTok | | Ident |
332 |------------| |-----------|
334 IMPORT Id1, .. Id# ; FROM Ident IMPORT Id1 .. Id# ;
340 All above stack discarded
343 PROCEDURE PCBuildImportInnerModule ;
347 BuildNulName - Pushes a NulKey onto the top of the stack.
359 PROCEDURE BuildNulName ;
363 BuildConst - builds a constant.
369 +------------+ +------------+
371 |------------+ |------------|
374 PROCEDURE BuildConst ;
381 PROCEDURE StartDesConst ;
388 PROCEDURE EndDesConst ;
392 BuildRelationConst - builds a relationship binary operation.
395 PROCEDURE BuildRelationConst ;
399 BuildUnaryConst - builds a unary operator node.
402 PROCEDURE BuildUnaryConst ;
406 BuildBinaryConst - builds a binary operator node.
409 PROCEDURE BuildBinaryConst ;
413 PushConstFunctionType -
416 PROCEDURE PushConstFunctionType ;
420 PushIntegerType - pushes a ztype or char leaf.
423 PROCEDURE PushIntegerType ;
430 PROCEDURE PushRType ;
437 PROCEDURE PushStringType ;
441 SkipConst - returns an alias to constant, sym, if one exists.
442 Otherwise sym is returned.
445 PROCEDURE SkipConst (sym: CARDINAL) : CARDINAL ;
449 PushConstType - pushes a constant to the expression stack.
452 PROCEDURE PushConstType ;
456 PushConstAttributeType -
459 PROCEDURE PushConstAttributeType ;
463 PushConstAttributePairType -
466 PROCEDURE PushConstAttributePairType ;
470 PushConstructorCastType -
473 PROCEDURE PushConstructorCastType ;
480 PROCEDURE PushInConstructor ;
487 PROCEDURE PopInConstructor ;
491 ResolveConstTypes - resolves the types of all designator declared constants.
494 PROCEDURE ResolveConstTypes ;