| 1 |
(* P3SymBuild.def pass 3 symbol creation. |
| 2 |
|
| 3 |
Copyright (C) 2001-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 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) |
| 11 |
any later version. |
| 12 |
|
| 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. |
| 17 |
|
| 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/>. *) |
| 21 |
|
| 22 |
DEFINITION MODULE P3SymBuild ; |
| 23 |
|
| 24 |
(* |
| 25 |
Title : P3SymBuild |
| 26 |
Author : Gaius Mulley |
| 27 |
Date : 24/6/87 |
| 28 |
System : UNIX (GNU Modula-2) |
| 29 |
Description: pass 3 symbol creation. |
| 30 |
*) |
| 31 |
|
| 32 |
|
| 33 |
(* |
| 34 |
StartBuildDefinitionModule - Creates a definition module and starts |
| 35 |
a new scope. |
| 36 |
|
| 37 |
The Stack is expected: |
| 38 |
|
| 39 |
Entry Exit |
| 40 |
|
| 41 |
Ptr -> <- Ptr |
| 42 |
+------------+ +-----------+ |
| 43 |
| NameStart | | NameStart | |
| 44 |
|------------| |-----------| |
| 45 |
|
| 46 |
*) |
| 47 |
|
| 48 |
PROCEDURE P3StartBuildDefModule ; |
| 49 |
|
| 50 |
|
| 51 |
(* |
| 52 |
EndBuildDefinitionModule - Destroys the definition module scope and |
| 53 |
checks for correct name. |
| 54 |
|
| 55 |
The Stack is expected: |
| 56 |
|
| 57 |
Entry Exit |
| 58 |
|
| 59 |
Ptr -> |
| 60 |
+------------+ +-----------+ |
| 61 |
| NameEnd | | | |
| 62 |
|------------| |-----------| |
| 63 |
| NameStart | | | <- Ptr |
| 64 |
|------------| |-----------| |
| 65 |
*) |
| 66 |
|
| 67 |
PROCEDURE P3EndBuildDefModule ; |
| 68 |
|
| 69 |
|
| 70 |
(* |
| 71 |
StartBuildImplementationModule - Creates an implementation module and starts |
| 72 |
a new scope. |
| 73 |
|
| 74 |
The Stack is expected: |
| 75 |
|
| 76 |
Entry Exit |
| 77 |
|
| 78 |
Ptr -> <- Ptr |
| 79 |
+------------+ +-----------+ |
| 80 |
| NameStart | | NameStart | |
| 81 |
|------------| |-----------| |
| 82 |
|
| 83 |
*) |
| 84 |
|
| 85 |
PROCEDURE P3StartBuildImpModule ; |
| 86 |
|
| 87 |
|
| 88 |
(* |
| 89 |
EndBuildImplementationModule - Destroys the implementation module scope and |
| 90 |
checks for correct name. |
| 91 |
|
| 92 |
The Stack is expected: |
| 93 |
|
| 94 |
Entry Exit |
| 95 |
|
| 96 |
Ptr -> |
| 97 |
+------------+ +-----------+ |
| 98 |
| NameEnd | | | |
| 99 |
|------------| |-----------| |
| 100 |
| NameStart | | | <- Ptr |
| 101 |
|------------| |-----------| |
| 102 |
*) |
| 103 |
|
| 104 |
PROCEDURE P3EndBuildImpModule ; |
| 105 |
|
| 106 |
|
| 107 |
(* |
| 108 |
StartBuildProgramModule - Creates a program module and starts |
| 109 |
a new scope. |
| 110 |
|
| 111 |
The Stack is expected: |
| 112 |
|
| 113 |
Entry Exit |
| 114 |
|
| 115 |
Ptr -> <- Ptr |
| 116 |
+------------+ +-----------+ |
| 117 |
| NameStart | | NameStart | |
| 118 |
|------------| |-----------| |
| 119 |
|
| 120 |
*) |
| 121 |
|
| 122 |
PROCEDURE P3StartBuildProgModule ; |
| 123 |
|
| 124 |
|
| 125 |
(* |
| 126 |
EndBuildProgramModule - Destroys the program module scope and |
| 127 |
checks for correct name. |
| 128 |
|
| 129 |
The Stack is expected: |
| 130 |
|
| 131 |
Entry Exit |
| 132 |
|
| 133 |
Ptr -> |
| 134 |
+------------+ +-----------+ |
| 135 |
| NameEnd | | | |
| 136 |
|------------| |-----------| |
| 137 |
| NameStart | | | <- Ptr |
| 138 |
|------------| |-----------| |
| 139 |
*) |
| 140 |
|
| 141 |
PROCEDURE P3EndBuildProgModule ; |
| 142 |
|
| 143 |
|
| 144 |
(* |
| 145 |
CheckCanBeImported - checks to see that it is legal to import, Sym, from, ModSym. |
| 146 |
*) |
| 147 |
|
| 148 |
PROCEDURE CheckCanBeImported (ModSym, Sym: CARDINAL) ; |
| 149 |
|
| 150 |
|
| 151 |
(* |
| 152 |
StartBuildInnerModule - Creates an Inner module and starts |
| 153 |
a new scope. |
| 154 |
|
| 155 |
The Stack is expected: |
| 156 |
|
| 157 |
Entry Exit |
| 158 |
|
| 159 |
Ptr -> <- Ptr |
| 160 |
+------------+ +-----------+ |
| 161 |
| NameStart | | NameStart | |
| 162 |
|------------| |-----------| |
| 163 |
|
| 164 |
*) |
| 165 |
|
| 166 |
PROCEDURE StartBuildInnerModule ; |
| 167 |
|
| 168 |
|
| 169 |
(* |
| 170 |
EndBuildInnerModule - Destroys the Inner module scope and |
| 171 |
checks for correct name. |
| 172 |
|
| 173 |
The Stack is expected: |
| 174 |
|
| 175 |
Entry Exit |
| 176 |
|
| 177 |
Ptr -> |
| 178 |
+------------+ +-----------+ |
| 179 |
| NameEnd | | | |
| 180 |
|------------| |-----------| |
| 181 |
| NameStart | | | <- Ptr |
| 182 |
|------------| |-----------| |
| 183 |
*) |
| 184 |
|
| 185 |
PROCEDURE EndBuildInnerModule ; |
| 186 |
|
| 187 |
|
| 188 |
(* |
| 189 |
CheckImportListOuterModule - checks to see that all identifiers are |
| 190 |
exported from the definition module. |
| 191 |
|
| 192 |
The Stack is expected: |
| 193 |
|
| 194 |
Entry OR Entry |
| 195 |
|
| 196 |
Ptr -> Ptr -> |
| 197 |
+------------+ +-----------+ |
| 198 |
| # | | # | |
| 199 |
|------------| |-----------| |
| 200 |
| Id1 | | Id1 | |
| 201 |
|------------| |-----------| |
| 202 |
. . . . |
| 203 |
. . . . |
| 204 |
. . . . |
| 205 |
|------------| |-----------| |
| 206 |
| Id# | | Id# | |
| 207 |
|------------| |-----------| |
| 208 |
| ImportTok | | Ident | |
| 209 |
|------------| |-----------| |
| 210 |
|
| 211 |
IMPORT Id1, .. Id# ; FROM Ident IMPORT Id1 .. Id# ; |
| 212 |
|
| 213 |
|
| 214 |
Error Condition |
| 215 |
Exit |
| 216 |
|
| 217 |
All above stack discarded |
| 218 |
*) |
| 219 |
|
| 220 |
PROCEDURE CheckImportListOuterModule ; |
| 221 |
|
| 222 |
|
| 223 |
(* |
| 224 |
BuildProcedureHeading - Builds a procedure heading for the definition |
| 225 |
module procedures. |
| 226 |
|
| 227 |
Operation only performed if compiling a |
| 228 |
definition module. |
| 229 |
|
| 230 |
The Stack: |
| 231 |
|
| 232 |
Entry Exit |
| 233 |
|
| 234 |
Ptr -> |
| 235 |
+------------+ |
| 236 |
| ProcSym | Empty |
| 237 |
|------------| |
| 238 |
|
| 239 |
*) |
| 240 |
|
| 241 |
PROCEDURE BuildProcedureHeading ; |
| 242 |
|
| 243 |
|
| 244 |
(* |
| 245 |
StartBuildProcedure - Builds a Procedure. |
| 246 |
|
| 247 |
The Stack: |
| 248 |
|
| 249 |
Entry Exit |
| 250 |
|
| 251 |
<- Ptr |
| 252 |
+------------+ |
| 253 |
Ptr -> | ProcSym | |
| 254 |
+------------+ |------------| |
| 255 |
| Name | | Name | |
| 256 |
|------------| |------------| |
| 257 |
*) |
| 258 |
|
| 259 |
PROCEDURE StartBuildProcedure ; |
| 260 |
|
| 261 |
|
| 262 |
(* |
| 263 |
EndBuildProcedure - Ends building a Procedure. |
| 264 |
It checks the start procedure name matches the end |
| 265 |
procedure name. |
| 266 |
|
| 267 |
The Stack: |
| 268 |
|
| 269 |
|
| 270 |
Entry Exit |
| 271 |
|
| 272 |
Ptr -> |
| 273 |
+------------+ |
| 274 |
| NameEnd | |
| 275 |
|------------| |
| 276 |
| ProcSym | |
| 277 |
|------------| |
| 278 |
| NameStart | |
| 279 |
|------------| |
| 280 |
Empty |
| 281 |
*) |
| 282 |
|
| 283 |
PROCEDURE EndBuildProcedure ; |
| 284 |
|
| 285 |
|
| 286 |
(* |
| 287 |
EndBuildForward - |
| 288 |
*) |
| 289 |
|
| 290 |
PROCEDURE EndBuildForward ; |
| 291 |
|
| 292 |
|
| 293 |
(* |
| 294 |
BuildSubrange - Builds a Subrange type Symbol. |
| 295 |
|
| 296 |
Stack |
| 297 |
|
| 298 |
Entry Exit |
| 299 |
|
| 300 |
Ptr -> |
| 301 |
+------------+ |
| 302 |
| High | |
| 303 |
|------------| |
| 304 |
| Low | <- Ptr |
| 305 |
|------------| |
| 306 |
*) |
| 307 |
|
| 308 |
PROCEDURE BuildSubrange ; |
| 309 |
|
| 310 |
|
| 311 |
(* |
| 312 |
BuildNulName - Pushes a NulKey onto the top of the stack. |
| 313 |
The Stack: |
| 314 |
|
| 315 |
|
| 316 |
Entry Exit |
| 317 |
|
| 318 |
<- Ptr |
| 319 |
Empty +------------+ |
| 320 |
| NulKey | |
| 321 |
|------------| |
| 322 |
*) |
| 323 |
|
| 324 |
PROCEDURE BuildNulName ; |
| 325 |
|
| 326 |
|
| 327 |
(* |
| 328 |
BuildConst - builds a constant. |
| 329 |
Stack |
| 330 |
|
| 331 |
Entry Exit |
| 332 |
|
| 333 |
Ptr -> <- Ptr |
| 334 |
+------------+ +------------+ |
| 335 |
| Name | | Sym | |
| 336 |
|------------+ |------------| |
| 337 |
*) |
| 338 |
|
| 339 |
PROCEDURE BuildConst ; |
| 340 |
|
| 341 |
|
| 342 |
(* |
| 343 |
BuildVarAtAddress - updates the symbol table entry of, variable sym, to be declared |
| 344 |
at address, address. |
| 345 |
|
| 346 |
Stack |
| 347 |
|
| 348 |
Entry Exit |
| 349 |
|
| 350 |
Ptr -> |
| 351 |
+--------------+ |
| 352 |
| Expr | EType | <- Ptr |
| 353 |
|--------------+ +--------------+ |
| 354 |
| name | SType | | name | SType | |
| 355 |
|--------------+ |--------------| |
| 356 |
*) |
| 357 |
|
| 358 |
PROCEDURE BuildVarAtAddress ; |
| 359 |
|
| 360 |
|
| 361 |
(* |
| 362 |
BuildOptArgInitializer - assigns the constant value symbol, const, to be the |
| 363 |
initial value of the optional parameter should it be |
| 364 |
absent. |
| 365 |
|
| 366 |
Ptr -> |
| 367 |
+------------+ |
| 368 |
| const | |
| 369 |
|------------| <- Ptr |
| 370 |
*) |
| 371 |
|
| 372 |
PROCEDURE BuildOptArgInitializer ; |
| 373 |
|
| 374 |
|
| 375 |
END P3SymBuild. |