| 1 |
(* P2SymBuild.def pass 2 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 P2SymBuild ; |
| 23 |
|
| 24 |
|
| 25 |
(* |
| 26 |
BlockStart - tokno is the module/procedure/implementation/definition token |
| 27 |
*) |
| 28 |
|
| 29 |
PROCEDURE BlockStart (tokno: CARDINAL) ; |
| 30 |
|
| 31 |
(* |
| 32 |
BlockEnd - declare module ctor/init/fini/dep procedures. |
| 33 |
*) |
| 34 |
|
| 35 |
PROCEDURE BlockEnd (tokno: CARDINAL) ; |
| 36 |
|
| 37 |
|
| 38 |
(* |
| 39 |
BlockBegin - assign curBeginTok to tokno. |
| 40 |
*) |
| 41 |
|
| 42 |
PROCEDURE BlockBegin (tokno: CARDINAL) ; |
| 43 |
|
| 44 |
|
| 45 |
(* |
| 46 |
BlockFinally - assign curFinallyTok to tokno. |
| 47 |
*) |
| 48 |
|
| 49 |
PROCEDURE BlockFinally (tokno: CARDINAL) ; |
| 50 |
|
| 51 |
|
| 52 |
(* |
| 53 |
StartBuildDefinitionModule - Creates a definition module and starts |
| 54 |
a new scope. |
| 55 |
|
| 56 |
The Stack is expected: |
| 57 |
|
| 58 |
Entry Exit |
| 59 |
|
| 60 |
Ptr -> <- Ptr |
| 61 |
+------------+ +-----------+ |
| 62 |
| NameStart | | NameStart | |
| 63 |
|------------| |-----------| |
| 64 |
|
| 65 |
*) |
| 66 |
|
| 67 |
PROCEDURE P2StartBuildDefModule ; |
| 68 |
|
| 69 |
|
| 70 |
(* |
| 71 |
EndBuildDefinitionModule - Destroys the definition module scope and |
| 72 |
checks for correct name. |
| 73 |
|
| 74 |
The Stack is expected: |
| 75 |
|
| 76 |
Entry Exit |
| 77 |
|
| 78 |
Ptr -> |
| 79 |
+------------+ +-----------+ |
| 80 |
| NameEnd | | | |
| 81 |
|------------| |-----------| |
| 82 |
| NameStart | | | <- Ptr |
| 83 |
|------------| |-----------| |
| 84 |
*) |
| 85 |
|
| 86 |
PROCEDURE P2EndBuildDefModule ; |
| 87 |
|
| 88 |
|
| 89 |
(* |
| 90 |
StartBuildImplementationModule - Creates an implementation module and starts |
| 91 |
a new scope. |
| 92 |
|
| 93 |
The Stack is expected: |
| 94 |
|
| 95 |
Entry Exit |
| 96 |
|
| 97 |
Ptr -> <- Ptr |
| 98 |
+------------+ +-----------+ |
| 99 |
| NameStart | | NameStart | |
| 100 |
|------------| |-----------| |
| 101 |
|
| 102 |
*) |
| 103 |
|
| 104 |
PROCEDURE P2StartBuildImplementationModule ; |
| 105 |
|
| 106 |
|
| 107 |
(* |
| 108 |
EndBuildImplementationModule - Destroys the implementation module scope and |
| 109 |
checks for correct name. |
| 110 |
|
| 111 |
The Stack is expected: |
| 112 |
|
| 113 |
Entry Exit |
| 114 |
|
| 115 |
Ptr -> |
| 116 |
+------------+ +-----------+ |
| 117 |
| NameEnd | | | |
| 118 |
|------------| |-----------| |
| 119 |
| NameStart | | | <- Ptr |
| 120 |
|------------| |-----------| |
| 121 |
*) |
| 122 |
|
| 123 |
PROCEDURE P2EndBuildImplementationModule ; |
| 124 |
|
| 125 |
|
| 126 |
(* |
| 127 |
StartBuildProgramModule - Creates a program module and starts |
| 128 |
a new scope. |
| 129 |
|
| 130 |
The Stack is expected: |
| 131 |
|
| 132 |
Entry Exit |
| 133 |
|
| 134 |
Ptr -> <- Ptr |
| 135 |
+------------+ +-----------+ |
| 136 |
| NameStart | | NameStart | |
| 137 |
|------------| |-----------| |
| 138 |
|
| 139 |
*) |
| 140 |
|
| 141 |
PROCEDURE P2StartBuildProgramModule ; |
| 142 |
|
| 143 |
|
| 144 |
(* |
| 145 |
EndBuildProgramModule - Destroys the program module scope and |
| 146 |
checks for correct name. |
| 147 |
|
| 148 |
The Stack is expected: |
| 149 |
|
| 150 |
Entry Exit |
| 151 |
|
| 152 |
Ptr -> |
| 153 |
+------------+ +-----------+ |
| 154 |
| NameEnd | | | |
| 155 |
|------------| |-----------| |
| 156 |
| NameStart | | | <- Ptr |
| 157 |
|------------| |-----------| |
| 158 |
*) |
| 159 |
|
| 160 |
PROCEDURE P2EndBuildProgramModule ; |
| 161 |
|
| 162 |
|
| 163 |
(* |
| 164 |
StartBuildInnerModule - Creates an Inner module and starts |
| 165 |
a new scope. |
| 166 |
|
| 167 |
The Stack is expected: |
| 168 |
|
| 169 |
Entry Exit |
| 170 |
|
| 171 |
Ptr -> <- Ptr |
| 172 |
+------------+ +-----------+ |
| 173 |
| NameStart | | NameStart | |
| 174 |
|------------| |-----------| |
| 175 |
|
| 176 |
*) |
| 177 |
|
| 178 |
PROCEDURE StartBuildInnerModule ; |
| 179 |
|
| 180 |
|
| 181 |
(* |
| 182 |
EndBuildInnerModule - Destroys the Inner module scope and |
| 183 |
checks for correct name. |
| 184 |
|
| 185 |
The Stack is expected: |
| 186 |
|
| 187 |
Entry Exit |
| 188 |
|
| 189 |
Ptr -> |
| 190 |
+------------+ +-----------+ |
| 191 |
| NameEnd | | | |
| 192 |
|------------| |-----------| |
| 193 |
| NameStart | | | <- Ptr |
| 194 |
|------------| |-----------| |
| 195 |
*) |
| 196 |
|
| 197 |
PROCEDURE EndBuildInnerModule ; |
| 198 |
|
| 199 |
|
| 200 |
(* |
| 201 |
BuildImportOuterModule - Builds imported identifiers into an outer module |
| 202 |
from a definition module. |
| 203 |
|
| 204 |
The Stack is expected: |
| 205 |
|
| 206 |
Entry OR Entry |
| 207 |
|
| 208 |
Ptr -> Ptr -> |
| 209 |
+------------+ +-----------+ |
| 210 |
| # | | # | |
| 211 |
|------------| |-----------| |
| 212 |
| Id1 | | Id1 | |
| 213 |
|------------| |-----------| |
| 214 |
. . . . |
| 215 |
. . . . |
| 216 |
. . . . |
| 217 |
|------------| |-----------| |
| 218 |
| Id# | | Id# | |
| 219 |
|------------| |-----------| |
| 220 |
| ImportTok | | Ident | |
| 221 |
|------------| |-----------| |
| 222 |
|
| 223 |
IMPORT Id1, .. Id# ; FROM Ident IMPORT Id1 .. Id# ; |
| 224 |
|
| 225 |
|
| 226 |
Error Condition |
| 227 |
Exit |
| 228 |
|
| 229 |
All above stack discarded |
| 230 |
*) |
| 231 |
|
| 232 |
PROCEDURE BuildImportOuterModule ; |
| 233 |
|
| 234 |
|
| 235 |
(* |
| 236 |
BuildExportOuterModule - Builds exported identifiers from an outer module |
| 237 |
to the outside world of library modules. |
| 238 |
|
| 239 |
The Stack is expected: |
| 240 |
|
| 241 |
Entry OR Entry |
| 242 |
|
| 243 |
Ptr -> Ptr -> |
| 244 |
+------------+ +--------------+ |
| 245 |
| # | | # | |
| 246 |
|------------| |--------------| |
| 247 |
| Id1 | | Id1 | |
| 248 |
|------------| |--------------| |
| 249 |
. . . . |
| 250 |
. . . . |
| 251 |
. . . . |
| 252 |
|------------| |--------------| |
| 253 |
| Id# | | Id# | |
| 254 |
|------------| |--------------| |
| 255 |
| ExportTok | | QualifiedTok | |
| 256 |
|------------| |--------------| |
| 257 |
|
| 258 |
EXPORT Id1, .. Id# ; EXPORT QUALIFIED Id1 .. Id# ; |
| 259 |
|
| 260 |
Error Condition |
| 261 |
|
| 262 |
|
| 263 |
Exit |
| 264 |
|
| 265 |
All above stack discarded |
| 266 |
*) |
| 267 |
|
| 268 |
PROCEDURE BuildExportOuterModule ; |
| 269 |
|
| 270 |
|
| 271 |
(* |
| 272 |
BuildImportInnerModule - Builds imported identifiers into an inner module |
| 273 |
from the last level of module. |
| 274 |
|
| 275 |
The Stack is expected: |
| 276 |
|
| 277 |
Entry OR Entry |
| 278 |
|
| 279 |
Ptr -> Ptr -> |
| 280 |
+------------+ +-----------+ |
| 281 |
| # | | # | |
| 282 |
|------------| |-----------| |
| 283 |
| Id1 | | Id1 | |
| 284 |
|------------| |-----------| |
| 285 |
. . . . |
| 286 |
. . . . |
| 287 |
. . . . |
| 288 |
|------------| |-----------| |
| 289 |
| Id# | | Id# | |
| 290 |
|------------| |-----------| |
| 291 |
| ImportTok | | Ident | |
| 292 |
|------------| |-----------| |
| 293 |
|
| 294 |
IMPORT Id1, .. Id# ; FROM Ident IMPORT Id1 .. Id# ; |
| 295 |
|
| 296 |
|
| 297 |
Error Condition |
| 298 |
Exit |
| 299 |
|
| 300 |
All above stack discarded |
| 301 |
*) |
| 302 |
|
| 303 |
PROCEDURE BuildImportInnerModule ; |
| 304 |
|
| 305 |
|
| 306 |
(* |
| 307 |
BuildExportInnerModule - Builds exported identifiers from an inner module |
| 308 |
to the next layer module. |
| 309 |
|
| 310 |
The Stack is expected: |
| 311 |
|
| 312 |
Entry OR Entry |
| 313 |
|
| 314 |
Ptr -> Ptr -> |
| 315 |
+------------+ +--------------+ |
| 316 |
| # | | # | |
| 317 |
|------------| |--------------| |
| 318 |
| Id1 | | Id1 | |
| 319 |
|------------| |--------------| |
| 320 |
. . . . |
| 321 |
. . . . |
| 322 |
. . . . |
| 323 |
|------------| |--------------| |
| 324 |
| Id# | | Id# | |
| 325 |
|------------| |--------------| |
| 326 |
| ExportTok | | QualifiedTok | |
| 327 |
|------------| |--------------| |
| 328 |
|
| 329 |
EXPORT Id1, .. Id# ; EXPORT QUALIFIED Id1 .. Id# ; |
| 330 |
|
| 331 |
|
| 332 |
Exit |
| 333 |
|
| 334 |
All above stack discarded |
| 335 |
*) |
| 336 |
|
| 337 |
PROCEDURE BuildExportInnerModule ; |
| 338 |
|
| 339 |
|
| 340 |
(* |
| 341 |
BuildNumber - Converts a number into a symbol. |
| 342 |
|
| 343 |
|
| 344 |
Stack |
| 345 |
|
| 346 |
Entry Exit |
| 347 |
|
| 348 |
Ptr -> <- Ptr |
| 349 |
+------------+ +------------+ |
| 350 |
| Name | | Sym | |
| 351 |
|------------+ |------------| |
| 352 |
*) |
| 353 |
|
| 354 |
PROCEDURE BuildNumber ; |
| 355 |
|
| 356 |
|
| 357 |
(* |
| 358 |
BuildString - Converts a string into a symbol. |
| 359 |
|
| 360 |
|
| 361 |
Stack |
| 362 |
|
| 363 |
Entry Exit |
| 364 |
|
| 365 |
Ptr -> <- Ptr |
| 366 |
+------------+ +------------+ |
| 367 |
| Name | | Sym | |
| 368 |
|------------+ |------------| |
| 369 |
*) |
| 370 |
|
| 371 |
PROCEDURE BuildString ; |
| 372 |
|
| 373 |
|
| 374 |
(* |
| 375 |
BuildConst - builds a constant. |
| 376 |
Stack |
| 377 |
|
| 378 |
Entry Exit |
| 379 |
|
| 380 |
Ptr -> |
| 381 |
+------------+ |
| 382 |
| Name | |
| 383 |
|------------+ <- Ptr |
| 384 |
*) |
| 385 |
|
| 386 |
PROCEDURE BuildConst ; |
| 387 |
|
| 388 |
|
| 389 |
(* |
| 390 |
StartBuildEnumeration - Builds an Enumeration type Type. |
| 391 |
|
| 392 |
|
| 393 |
Stack |
| 394 |
|
| 395 |
Entry Exit |
| 396 |
|
| 397 |
Ptr -> |
| 398 |
+------------+ |
| 399 |
| # | |
| 400 |
|------------| |
| 401 |
| en 1 | |
| 402 |
|------------| |
| 403 |
| en 2 | |
| 404 |
|------------| |
| 405 |
. . |
| 406 |
. . |
| 407 |
. . <- Ptr |
| 408 |
|------------| +------------+ |
| 409 |
| en # | | Type | |
| 410 |
|------------| |------------| |
| 411 |
| Name | | Name | |
| 412 |
|------------| |------------| |
| 413 |
*) |
| 414 |
|
| 415 |
PROCEDURE StartBuildEnumeration ; |
| 416 |
|
| 417 |
|
| 418 |
(* |
| 419 |
BuildSubrange - Builds a Subrange type Symbol, the base type can also be |
| 420 |
supplied if known. |
| 421 |
|
| 422 |
Stack |
| 423 |
|
| 424 |
Entry Exit |
| 425 |
|
| 426 |
|
| 427 |
<- Ptr |
| 428 |
+------------+ |
| 429 |
Ptr -> | Type | |
| 430 |
+------------+ |------------| |
| 431 |
| Name | | Name | |
| 432 |
|------------| |------------| |
| 433 |
*) |
| 434 |
|
| 435 |
PROCEDURE BuildSubrange (tok: CARDINAL; Base: CARDINAL) ; |
| 436 |
|
| 437 |
|
| 438 |
(* |
| 439 |
BuildAligned - builds an alignment constant symbol which is placed onto |
| 440 |
the stack. It expects the ident ALIGNED to be on the |
| 441 |
stack. |
| 442 |
|
| 443 |
Stack |
| 444 |
|
| 445 |
Entry Exit |
| 446 |
|
| 447 |
|
| 448 |
Ptr -> <- Ptr |
| 449 |
+---------------+ +-----------------+ |
| 450 |
| bytealignment | | AlignmentConst | |
| 451 |
+---------------+ |-----------------| |
| 452 |
*) |
| 453 |
|
| 454 |
PROCEDURE BuildAligned ; |
| 455 |
|
| 456 |
|
| 457 |
(* |
| 458 |
BuildVarAlignment - the AlignmentConst is either a temporary or NulSym. |
| 459 |
A type may only have one alignment value and |
| 460 |
error checking is performed. |
| 461 |
|
| 462 |
Stack |
| 463 |
|
| 464 |
Entry Exit |
| 465 |
|
| 466 |
|
| 467 |
Ptr -> |
| 468 |
+-----------------+ |
| 469 |
| AlignmentConst | <- Ptr |
| 470 |
|-----------------| +------------------+ |
| 471 |
| Type | | Type | TypeName | |
| 472 |
|-----------------| |------------------| |
| 473 |
*) |
| 474 |
|
| 475 |
PROCEDURE BuildVarAlignment ; |
| 476 |
|
| 477 |
|
| 478 |
(* |
| 479 |
BuildTypeAlignment - the AlignmentConst is either a temporary or NulSym. |
| 480 |
A type may only have one alignment value and |
| 481 |
error checking is performed. |
| 482 |
|
| 483 |
Stack |
| 484 |
|
| 485 |
Entry Exit |
| 486 |
|
| 487 |
|
| 488 |
Ptr -> |
| 489 |
+-----------------+ |
| 490 |
| AlignmentConst | |
| 491 |
|-----------------| |
| 492 |
| Type | Empty |
| 493 |
|-----------------| |
| 494 |
*) |
| 495 |
|
| 496 |
PROCEDURE BuildTypeAlignment ; |
| 497 |
|
| 498 |
|
| 499 |
(* |
| 500 |
BuildDefaultFieldAlignment - |
| 501 |
|
| 502 |
The Stack: |
| 503 |
|
| 504 |
Entry Exit |
| 505 |
===== ==== |
| 506 |
|
| 507 |
|
| 508 |
Ptr -> |
| 509 |
+-----------+ |
| 510 |
| Alignment | |
| 511 |
|-----------| +-----------+ |
| 512 |
| RecordSym | | RecordSym | |
| 513 |
|-----------| |-----------| |
| 514 |
| Name | | Name | |
| 515 |
|-----------| |-----------| |
| 516 |
|
| 517 |
*) |
| 518 |
|
| 519 |
PROCEDURE P2BuildDefaultFieldAlignment ; |
| 520 |
|
| 521 |
|
| 522 |
(* |
| 523 |
BuildPragmaConst - pushes a constant to the stack and stores it away into the |
| 524 |
const fifo queue ready for pass 3. |
| 525 |
*) |
| 526 |
|
| 527 |
PROCEDURE BuildPragmaConst ; |
| 528 |
|
| 529 |
|
| 530 |
(* |
| 531 |
BuildVariable - Builds variables listed in an IdentList with a Type. |
| 532 |
|
| 533 |
Stack |
| 534 |
|
| 535 |
Entry Exit |
| 536 |
|
| 537 |
Ptr -> |
| 538 |
+------------+ +------------+ |
| 539 |
| Type | Name| | | |
| 540 |
|------------| |------------| |
| 541 |
| # | | | |
| 542 |
|------------| |------------| |
| 543 |
| Ident 1 | | | |
| 544 |
|------------| |------------| |
| 545 |
| Ident 2 | | | |
| 546 |
|------------| |------------| |
| 547 |
. . . . |
| 548 |
. . . . |
| 549 |
. . . . |
| 550 |
|------------| |------------| |
| 551 |
| Ident # | | | <- Ptr |
| 552 |
|------------| |------------| |
| 553 |
|
| 554 |
Empty |
| 555 |
*) |
| 556 |
|
| 557 |
PROCEDURE BuildVariable ; |
| 558 |
|
| 559 |
|
| 560 |
(* |
| 561 |
BuildType - Builds a Type. |
| 562 |
|
| 563 |
|
| 564 |
Stack |
| 565 |
|
| 566 |
Entry Exit |
| 567 |
|
| 568 |
Ptr -> |
| 569 |
+------------+ |
| 570 |
| Type | <- Ptr |
| 571 |
|------------| +---------------+ |
| 572 |
| Name | | Type | Name | |
| 573 |
|------------| |---------------| |
| 574 |
|
| 575 |
Empty |
| 576 |
*) |
| 577 |
|
| 578 |
PROCEDURE BuildType ; |
| 579 |
|
| 580 |
|
| 581 |
(* |
| 582 |
StartBuildFormalParameters - Initialises the quadruple stack for |
| 583 |
Formal Parameters. |
| 584 |
|
| 585 |
The Stack: |
| 586 |
|
| 587 |
Entry Exit |
| 588 |
|
| 589 |
<- Ptr |
| 590 |
+------------+ |
| 591 |
Empty | 0 | |
| 592 |
|------------| |
| 593 |
*) |
| 594 |
|
| 595 |
PROCEDURE StartBuildFormalParameters ; |
| 596 |
|
| 597 |
|
| 598 |
(* |
| 599 |
EndBuildFormalParameters - Resets the quadruple stack after building |
| 600 |
Formal Parameters. |
| 601 |
|
| 602 |
The Stack: |
| 603 |
|
| 604 |
Entry Exit |
| 605 |
|
| 606 |
Ptr -> |
| 607 |
+------------+ |
| 608 |
| NoOfParam | <- Ptr |
| 609 |
|------------| +------------+ |
| 610 |
| ProcSym | | ProcSym | |
| 611 |
|------------| |------------| |
| 612 |
*) |
| 613 |
|
| 614 |
PROCEDURE EndBuildFormalParameters ; |
| 615 |
|
| 616 |
|
| 617 |
(* |
| 618 |
BuildProcedureHeading - Builds a procedure heading for the definition |
| 619 |
module procedures. |
| 620 |
|
| 621 |
Operation only performed if compiling a |
| 622 |
definition module. |
| 623 |
|
| 624 |
The Stack: |
| 625 |
|
| 626 |
Entry Exit |
| 627 |
|
| 628 |
Ptr -> |
| 629 |
+------------+ |
| 630 |
| ProcSym | Empty |
| 631 |
|------------| |
| 632 |
|
| 633 |
*) |
| 634 |
|
| 635 |
PROCEDURE BuildProcedureHeading ; |
| 636 |
|
| 637 |
|
| 638 |
(* |
| 639 |
BuildFunction - Builds a procedures return type. |
| 640 |
Procedure becomes a function. |
| 641 |
|
| 642 |
The Stack: |
| 643 |
|
| 644 |
Entry Exit |
| 645 |
|
| 646 |
Ptr -> |
| 647 |
+------------+ |
| 648 |
| TypeSym | <- Ptr |
| 649 |
|------------| +------------+ |
| 650 |
| ProcSym | | ProcSym | |
| 651 |
|------------| |------------| |
| 652 |
*) |
| 653 |
|
| 654 |
PROCEDURE BuildFunction ; |
| 655 |
|
| 656 |
|
| 657 |
(* |
| 658 |
BuildOptFunction - Builds a procedures optional return type. |
| 659 |
Procedure becomes a function and the user |
| 660 |
can either call it as a function or a procedure. |
| 661 |
|
| 662 |
The Stack: |
| 663 |
|
| 664 |
Entry Exit |
| 665 |
|
| 666 |
Ptr -> |
| 667 |
+------------+ |
| 668 |
| TypeSym | <- Ptr |
| 669 |
|------------| +------------+ |
| 670 |
| ProcSym | | ProcSym | |
| 671 |
|------------| |------------| |
| 672 |
*) |
| 673 |
|
| 674 |
PROCEDURE BuildOptFunction ; |
| 675 |
|
| 676 |
|
| 677 |
(* |
| 678 |
BuildFPSection - Builds a Formal Parameter in a procedure. |
| 679 |
|
| 680 |
The Stack: |
| 681 |
|
| 682 |
Entry Exit |
| 683 |
|
| 684 |
Ptr -> |
| 685 |
+------------+ |
| 686 |
| ParamTotal | |
| 687 |
|------------| |
| 688 |
| TypeName | |
| 689 |
|------------| |
| 690 |
| Array/Nul | |
| 691 |
|------------| |
| 692 |
| NoOfIds | |
| 693 |
|------------| |
| 694 |
| Id 1 | |
| 695 |
|------------| |
| 696 |
. . |
| 697 |
. . |
| 698 |
. . |
| 699 |
|------------| |
| 700 |
| Id n | <- Ptr |
| 701 |
|------------| +------------+ |
| 702 |
| Var / Nul | | ParamTotal | |
| 703 |
|------------| |------------| |
| 704 |
| ProcSym | | ProcSym | |
| 705 |
|------------| |------------| |
| 706 |
*) |
| 707 |
|
| 708 |
PROCEDURE BuildFPSection ; |
| 709 |
|
| 710 |
|
| 711 |
(* |
| 712 |
BuildVarArgs - indicates that the ProcSym takes varargs |
| 713 |
after ParamTotal. |
| 714 |
<- Ptr |
| 715 |
+------------+ +------------+ |
| 716 |
| ParamTotal | | ParamTotal | |
| 717 |
|------------| |------------| |
| 718 |
| ProcSym | | ProcSym | |
| 719 |
|------------| |------------| |
| 720 |
|
| 721 |
*) |
| 722 |
|
| 723 |
PROCEDURE BuildVarArgs ; |
| 724 |
|
| 725 |
|
| 726 |
(* |
| 727 |
BuildFormalVarArgs - indicates that the procedure type takes varargs. |
| 728 |
<- Ptr |
| 729 |
+------------+ +------------+ |
| 730 |
| ProcSym | | ProcSym | |
| 731 |
|------------| |------------| |
| 732 |
|
| 733 |
*) |
| 734 |
|
| 735 |
PROCEDURE BuildFormalVarArgs ; |
| 736 |
|
| 737 |
|
| 738 |
(* |
| 739 |
BuildOptArg - indicates that the ProcSym takes a single optarg |
| 740 |
after ParamTotal. |
| 741 |
|
| 742 |
<- Ptr |
| 743 |
+------------+ +------------+ |
| 744 |
| ParamTotal | | ParamTotal | |
| 745 |
|------------| |------------| |
| 746 |
| ProcSym | | ProcSym | |
| 747 |
|------------| |------------| |
| 748 |
*) |
| 749 |
|
| 750 |
PROCEDURE BuildOptArg ; |
| 751 |
|
| 752 |
|
| 753 |
(* |
| 754 |
StartBuildProcedure - Builds a Procedure. |
| 755 |
|
| 756 |
The Stack: |
| 757 |
|
| 758 |
Entry Exit |
| 759 |
|
| 760 |
<- Ptr |
| 761 |
+------------+ |
| 762 |
Ptr -> | ProcSym | |
| 763 |
+------------+ |------------| |
| 764 |
| Name | | Name | |
| 765 |
|------------| |------------| |
| 766 |
*) |
| 767 |
|
| 768 |
PROCEDURE StartBuildProcedure ; |
| 769 |
|
| 770 |
|
| 771 |
(* |
| 772 |
EndBuildProcedure - Ends building a Procedure. |
| 773 |
It checks the start procedure name matches the end |
| 774 |
procedure name. |
| 775 |
|
| 776 |
The Stack: |
| 777 |
|
| 778 |
|
| 779 |
Entry Exit |
| 780 |
|
| 781 |
Ptr -> |
| 782 |
+------------+ |
| 783 |
| NameEnd | |
| 784 |
|------------| |
| 785 |
| ProcSym | |
| 786 |
|------------| |
| 787 |
| NameStart | |
| 788 |
|------------| |
| 789 |
Empty |
| 790 |
*) |
| 791 |
|
| 792 |
PROCEDURE EndBuildProcedure ; |
| 793 |
|
| 794 |
|
| 795 |
(* |
| 796 |
EndBuildForward - ends building a forward procedure. |
| 797 |
*) |
| 798 |
|
| 799 |
PROCEDURE EndBuildForward ; |
| 800 |
|
| 801 |
|
| 802 |
(* |
| 803 |
BuildNoReturnAttribute - provide an interface to the symbol table module. |
| 804 |
*) |
| 805 |
|
| 806 |
PROCEDURE BuildNoReturnAttribute ; |
| 807 |
|
| 808 |
|
| 809 |
(* |
| 810 |
CheckProcedure - checks to see that the top of stack procedure |
| 811 |
has not been declared as a procedure function. |
| 812 |
|
| 813 |
The Stack: |
| 814 |
|
| 815 |
Entry Exit |
| 816 |
|
| 817 |
Ptr -> <- Ptr |
| 818 |
+------------+ +------------+ |
| 819 |
| ProcSym | | ProcSym | |
| 820 |
|------------| |------------| |
| 821 |
*) |
| 822 |
|
| 823 |
PROCEDURE CheckProcedure ; |
| 824 |
|
| 825 |
|
| 826 |
(* |
| 827 |
BuildPointerType - builds a pointer type. |
| 828 |
The Stack: |
| 829 |
|
| 830 |
Entry Exit |
| 831 |
===== ==== |
| 832 |
|
| 833 |
|
| 834 |
Ptr -> <- Ptr |
| 835 |
+------------+ +-------------+ |
| 836 |
| Type | | PointerType | |
| 837 |
|------------| |-------------| |
| 838 |
| Name | | Name | |
| 839 |
|------------| |-------------| |
| 840 |
*) |
| 841 |
|
| 842 |
PROCEDURE BuildPointerType (pointerpos: CARDINAL) ; |
| 843 |
|
| 844 |
|
| 845 |
(* |
| 846 |
BuildSetType - builds a set type. |
| 847 |
The Stack: |
| 848 |
|
| 849 |
Entry Exit |
| 850 |
===== ==== |
| 851 |
|
| 852 |
|
| 853 |
Ptr -> <- Ptr |
| 854 |
+------------+ +-------------+ |
| 855 |
| Type | | SetType | |
| 856 |
|------------| |-------------| |
| 857 |
| Name | | Name | |
| 858 |
|------------| |-------------| |
| 859 |
*) |
| 860 |
|
| 861 |
PROCEDURE BuildSetType (setpos: CARDINAL; ispacked: BOOLEAN) ; |
| 862 |
|
| 863 |
|
| 864 |
(* |
| 865 |
BuildRecord - Builds a record type. |
| 866 |
The Stack: |
| 867 |
|
| 868 |
Entry Exit |
| 869 |
===== ==== |
| 870 |
|
| 871 |
<- Ptr |
| 872 |
+-----------+ |
| 873 |
Ptr -> | RecordSym | |
| 874 |
+------------+ |-----------| |
| 875 |
| Name | | Name | |
| 876 |
|------------| |-----------| |
| 877 |
*) |
| 878 |
|
| 879 |
PROCEDURE BuildRecord ; |
| 880 |
|
| 881 |
|
| 882 |
(* |
| 883 |
BuildFieldRecord - Builds a field into a record sym. |
| 884 |
The Stack: |
| 885 |
|
| 886 |
|
| 887 |
Entry Exit |
| 888 |
===== ==== |
| 889 |
|
| 890 |
Ptr -> |
| 891 |
+-------------+ |
| 892 |
| Alignment | |
| 893 |
|-------------| |
| 894 |
| Type | Name | |
| 895 |
|-------------| |
| 896 |
| n | |
| 897 |
|-------------| |
| 898 |
| Id 1 | |
| 899 |
|-------------| |
| 900 |
. . |
| 901 |
. . |
| 902 |
. . |
| 903 |
|-------------| |
| 904 |
| Id n | <- Ptr |
| 905 |
|-------------| +-------------+ |
| 906 |
| RecordSym | | RecordSym | |
| 907 |
|-------------| |-------------| |
| 908 |
| RecordName | | RecordName | |
| 909 |
|-------------| |-------------| |
| 910 |
*) |
| 911 |
|
| 912 |
PROCEDURE BuildFieldRecord ; |
| 913 |
|
| 914 |
|
| 915 |
(* |
| 916 |
StartBuildVarient - Builds a varient symbol on top of a record sym. |
| 917 |
The Stack: |
| 918 |
|
| 919 |
|
| 920 |
Entry Exit |
| 921 |
===== ==== |
| 922 |
|
| 923 |
<- Ptr |
| 924 |
+-------------+ |
| 925 |
Ptr -> | VarientSym | |
| 926 |
+-------------+ |-------------| |
| 927 |
| RecordSym | | RecordSym | |
| 928 |
|-------------| |-------------| |
| 929 |
| RecordName | | RecordName | |
| 930 |
|-------------| |-------------| |
| 931 |
*) |
| 932 |
|
| 933 |
PROCEDURE StartBuildVarient ; |
| 934 |
|
| 935 |
|
| 936 |
(* |
| 937 |
EndBuildVarient - Removes the varient symbol from the stack. |
| 938 |
The Stack: |
| 939 |
|
| 940 |
Entry Exit |
| 941 |
===== ==== |
| 942 |
|
| 943 |
Ptr -> |
| 944 |
+-------------+ |
| 945 |
| VarientSym | <- Ptr |
| 946 |
|-------------| +-------------+ |
| 947 |
| RecordSym | | RecordSym | |
| 948 |
|-------------| |-------------| |
| 949 |
| RecordName | | RecordName | |
| 950 |
|-------------| |-------------| |
| 951 |
*) |
| 952 |
|
| 953 |
PROCEDURE EndBuildVarient ; |
| 954 |
|
| 955 |
|
| 956 |
(* |
| 957 |
BuildVarientSelector - Builds a field into a record sym. |
| 958 |
The Stack: |
| 959 |
|
| 960 |
|
| 961 |
Entry Exit |
| 962 |
===== ==== |
| 963 |
|
| 964 |
Ptr -> |
| 965 |
+-------------+ |
| 966 |
| Qualident | |
| 967 |
|-------------| |
| 968 |
| Ident | <- Ptr |
| 969 |
|-------------| +-------------+ |
| 970 |
| RecordSym | | RecordSym | |
| 971 |
|-------------| |-------------| |
| 972 |
*) |
| 973 |
|
| 974 |
PROCEDURE BuildVarientSelector ; |
| 975 |
|
| 976 |
|
| 977 |
(* |
| 978 |
StartBuildVarientFieldRecord - Builds a varient field into a varient sym. |
| 979 |
The Stack: |
| 980 |
|
| 981 |
|
| 982 |
Entry Exit |
| 983 |
===== ==== |
| 984 |
|
| 985 |
<- Ptr |
| 986 |
+-------------+ |
| 987 |
Ptr -> | VarientField| |
| 988 |
+-------------+ |-------------| |
| 989 |
| VarientSym | | RecordSym | |
| 990 |
|-------------| |-------------| |
| 991 |
*) |
| 992 |
|
| 993 |
PROCEDURE StartBuildVarientFieldRecord ; |
| 994 |
|
| 995 |
|
| 996 |
(* |
| 997 |
EndBuildVarientFieldRecord - Removes a varient field from the stack. |
| 998 |
The Stack: |
| 999 |
|
| 1000 |
|
| 1001 |
Entry Exit |
| 1002 |
===== ==== |
| 1003 |
|
| 1004 |
Ptr -> |
| 1005 |
+-------------+ |
| 1006 |
| VarientField| <- Ptr |
| 1007 |
|-------------| +-------------+ |
| 1008 |
| VarientSym | | VarientSym | |
| 1009 |
|-------------| |-------------| |
| 1010 |
*) |
| 1011 |
|
| 1012 |
PROCEDURE EndBuildVarientFieldRecord ; |
| 1013 |
|
| 1014 |
|
| 1015 |
(* |
| 1016 |
BuildNulName - Pushes a NulKey onto the top of the stack. |
| 1017 |
The Stack: |
| 1018 |
|
| 1019 |
|
| 1020 |
Entry Exit |
| 1021 |
|
| 1022 |
<- Ptr |
| 1023 |
Empty +------------+ |
| 1024 |
| NulKey | |
| 1025 |
|------------| |
| 1026 |
*) |
| 1027 |
|
| 1028 |
PROCEDURE BuildNulName ; |
| 1029 |
|
| 1030 |
|
| 1031 |
(* |
| 1032 |
BuildTypeEnd - Pops the type Type and Name. |
| 1033 |
The Stack: |
| 1034 |
|
| 1035 |
|
| 1036 |
Entry Exit |
| 1037 |
|
| 1038 |
|
| 1039 |
Ptr -> |
| 1040 |
+-------------+ |
| 1041 |
| Type | Name | Empty |
| 1042 |
|-------------| |
| 1043 |
*) |
| 1044 |
|
| 1045 |
PROCEDURE BuildTypeEnd ; |
| 1046 |
|
| 1047 |
|
| 1048 |
(* |
| 1049 |
StartBuildArray - Builds an array type. |
| 1050 |
The Stack: |
| 1051 |
|
| 1052 |
Entry Exit |
| 1053 |
===== ==== |
| 1054 |
|
| 1055 |
<- Ptr |
| 1056 |
+-----------+ |
| 1057 |
Ptr -> | ArraySym | |
| 1058 |
+------------+ |-----------| |
| 1059 |
| Name | | Name | |
| 1060 |
|------------| |-----------| |
| 1061 |
*) |
| 1062 |
|
| 1063 |
PROCEDURE StartBuildArray ; |
| 1064 |
|
| 1065 |
|
| 1066 |
(* |
| 1067 |
EndBuildArray - Builds an array type. |
| 1068 |
The Stack: |
| 1069 |
|
| 1070 |
Entry Exit |
| 1071 |
===== ==== |
| 1072 |
|
| 1073 |
Ptr -> |
| 1074 |
+------------+ |
| 1075 |
| TypeSym | <- Ptr |
| 1076 |
|------------| +------------+ |
| 1077 |
| ArraySym | | ArraySym | |
| 1078 |
|------------| |------------| |
| 1079 |
| Name | | Name | |
| 1080 |
|------------| |------------| |
| 1081 |
*) |
| 1082 |
|
| 1083 |
PROCEDURE EndBuildArray ; |
| 1084 |
|
| 1085 |
|
| 1086 |
(* |
| 1087 |
BuildFieldArray - Builds a field into an array sym. |
| 1088 |
The Stack: |
| 1089 |
|
| 1090 |
|
| 1091 |
Entry Exit |
| 1092 |
===== ==== |
| 1093 |
|
| 1094 |
Ptr -> |
| 1095 |
+-------------+ |
| 1096 |
| Type | Name | <- Ptr |
| 1097 |
|-------------| +-------------+ |
| 1098 |
| ArraySym | | ArraySym | |
| 1099 |
|-------------| |-------------| |
| 1100 |
| ArrayName | | ArrayName | |
| 1101 |
|-------------| |-------------| |
| 1102 |
*) |
| 1103 |
|
| 1104 |
PROCEDURE BuildFieldArray ; |
| 1105 |
|
| 1106 |
|
| 1107 |
(* |
| 1108 |
BuildArrayComma - converts ARRAY [..], [..] OF into ARRAY [..] OF ARRAY [..] |
| 1109 |
|
| 1110 |
|
| 1111 |
Ptr -> <- Ptr |
| 1112 |
+-------------+ +-------------+ |
| 1113 |
| ArraySym1 | | ArraySym2 | |
| 1114 |
|-------------| |-------------| |
| 1115 |
| ArrayName | | ArrayName | |
| 1116 |
|-------------| |-------------| |
| 1117 |
*) |
| 1118 |
|
| 1119 |
PROCEDURE BuildArrayComma ; |
| 1120 |
|
| 1121 |
|
| 1122 |
(* |
| 1123 |
BuildProcedureType - builds a procedure type symbol. |
| 1124 |
The Stack: |
| 1125 |
|
| 1126 |
|
| 1127 |
<- Ptr |
| 1128 |
+-------------+ |
| 1129 |
Ptr -> | ProcTypeSym | |
| 1130 |
+-------------+ |-------------| |
| 1131 |
| Name | | Name | |
| 1132 |
|-------------| |-------------| |
| 1133 |
*) |
| 1134 |
|
| 1135 |
PROCEDURE BuildProcedureType ; |
| 1136 |
|
| 1137 |
|
| 1138 |
(* |
| 1139 |
BuildFormalType - Builds a Formal Parameter in a procedure type. |
| 1140 |
|
| 1141 |
The Stack: |
| 1142 |
|
| 1143 |
Entry Exit |
| 1144 |
|
| 1145 |
Ptr -> |
| 1146 |
+------------+ |
| 1147 |
| TypeSym | |
| 1148 |
|------------| |
| 1149 |
| Array/Nul | |
| 1150 |
|------------| |
| 1151 |
| Var / Nul | <- Ptr |
| 1152 |
|------------| +--------------+ |
| 1153 |
| ProcTypeSym| | ProcTypeSym | |
| 1154 |
|------------| |--------------| |
| 1155 |
*) |
| 1156 |
|
| 1157 |
PROCEDURE BuildFormalType ; |
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
(* |
| 1162 |
SeenUnknown - sets the operand type to unknown. |
| 1163 |
*) |
| 1164 |
|
| 1165 |
PROCEDURE SeenUnknown ; |
| 1166 |
|
| 1167 |
|
| 1168 |
(* |
| 1169 |
SeenCast - sets the operand type to cast. |
| 1170 |
*) |
| 1171 |
|
| 1172 |
PROCEDURE SeenCast (sym: CARDINAL) ; |
| 1173 |
|
| 1174 |
|
| 1175 |
(* |
| 1176 |
SeenSet - sets the operand type to set. |
| 1177 |
*) |
| 1178 |
|
| 1179 |
PROCEDURE SeenSet ; |
| 1180 |
|
| 1181 |
|
| 1182 |
(* |
| 1183 |
SeenConstructor - sets the operand type to constructor. |
| 1184 |
*) |
| 1185 |
|
| 1186 |
PROCEDURE SeenConstructor ; |
| 1187 |
|
| 1188 |
|
| 1189 |
(* |
| 1190 |
SeenArray - sets the operand type to array. |
| 1191 |
*) |
| 1192 |
|
| 1193 |
PROCEDURE SeenArray ; |
| 1194 |
|
| 1195 |
|
| 1196 |
(* |
| 1197 |
SeenString - sets the operand type to string. |
| 1198 |
*) |
| 1199 |
|
| 1200 |
PROCEDURE SeenString ; |
| 1201 |
|
| 1202 |
|
| 1203 |
(* |
| 1204 |
SeenBoolean - sets the operand type to a BOOLEAN. |
| 1205 |
*) |
| 1206 |
|
| 1207 |
PROCEDURE SeenBoolean ; |
| 1208 |
|
| 1209 |
|
| 1210 |
(* |
| 1211 |
SeenZType - sets the operand type to a Z type. |
| 1212 |
*) |
| 1213 |
|
| 1214 |
PROCEDURE SeenZType ; |
| 1215 |
|
| 1216 |
|
| 1217 |
(* |
| 1218 |
SeenRType - sets the operand type to a R type. |
| 1219 |
*) |
| 1220 |
|
| 1221 |
PROCEDURE SeenRType ; |
| 1222 |
|
| 1223 |
|
| 1224 |
(* |
| 1225 |
SeenCType - sets the operand type to a C type. |
| 1226 |
*) |
| 1227 |
|
| 1228 |
PROCEDURE SeenCType ; |
| 1229 |
|
| 1230 |
|
| 1231 |
(* |
| 1232 |
DetermineType - assigns the top of stack symbol with the type of |
| 1233 |
constant expression, if known. |
| 1234 |
*) |
| 1235 |
|
| 1236 |
PROCEDURE DetermineType ; |
| 1237 |
|
| 1238 |
|
| 1239 |
(* |
| 1240 |
PushType - pushes the current constant type. |
| 1241 |
*) |
| 1242 |
|
| 1243 |
PROCEDURE PushType ; |
| 1244 |
|
| 1245 |
|
| 1246 |
(* |
| 1247 |
PopType - pops the stacked type. |
| 1248 |
*) |
| 1249 |
|
| 1250 |
PROCEDURE PopType ; |
| 1251 |
|
| 1252 |
|
| 1253 |
(* |
| 1254 |
PushRememberConstant - |
| 1255 |
*) |
| 1256 |
|
| 1257 |
PROCEDURE PushRememberConstant ; |
| 1258 |
|
| 1259 |
|
| 1260 |
(* |
| 1261 |
PopRememberConstant - |
| 1262 |
*) |
| 1263 |
|
| 1264 |
PROCEDURE PopRememberConstant ; |
| 1265 |
|
| 1266 |
|
| 1267 |
(* |
| 1268 |
RememberConstant - |
| 1269 |
*) |
| 1270 |
|
| 1271 |
PROCEDURE RememberConstant (sym: CARDINAL) ; |
| 1272 |
|
| 1273 |
|
| 1274 |
END P2SymBuild. |