Debian Codegraph @

gcc/m2/gm2-compiler/M2Quads.def

raw
1 (* M2Quads.def generates quadruples.
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 M2Quads ;
23
24 (*
25 Author : Gaius Mulley
26 Title : M2Quads
27 Date : 3/6/87
28 Description: generates quadruples.
29 *)
30
31 FROM SYSTEM IMPORT WORD ;
32 FROM DynamicStrings IMPORT String ;
33
34 EXPORT QUALIFIED StartBuildDefFile, StartBuildModFile, EndBuildFile,
35 BuildModuleStart, BuildScaffold,
36 StartBuildInit, EndBuildInit,
37 StartBuildFinally, EndBuildFinally,
38 BuildExceptInitial, BuildExceptFinally,
39 BuildExceptProcedure,
40 BuildRetry,
41 BuildReThrow,
42 BuildBuiltinConst, BuildBuiltinTypeInfo,
43 BuildAssignment, BuildAssignConstant,
44 BuildAlignment,
45 BuildDefaultFieldAlignment, BuildPragmaField,
46 BuildRepeat, BuildUntil,
47 BuildWhile, BuildDoWhile, BuildEndWhile,
48 BuildLoop, BuildExit, BuildEndLoop,
49 BuildThenIf, BuildElse, BuildEndIf,
50 BuildElsif1, BuildElsif2,
51 BuildForToByDo, BuildPseudoBy, BuildEndFor,
52 BuildCaseStartStatementSequence,
53 BuildCaseEndStatementSequence,
54 BuildCaseList,
55 BuildCaseStart,
56 BuildCaseOr,
57 BuildCaseElse, BuildCaseEnd, BuildCaseCheck,
58 BuildCaseRange, BuildCaseEquality,
59 BuildNulParam, BuildProcedureCall,
60 CheckBuildFunction,
61 BuildFunctionCall, BuildConstFunctionCall,
62 BuildProcedureStart, BuildProcedureEnd,
63 BuildProcedureBegin,
64 BuildReturn,
65 BuildModulePriority,
66 BuildBooleanVariable,
67 BuildSizeCheckStart,
68 StartBuildWith, EndBuildWith, CheckWithReference,
69 BuildDesignatorRecord,
70 BuildDesignatorArray,
71 BuildDesignatorPointer,
72 BuildSetStart, BuildSetEnd,
73 BuildEmptySet,
74 BuildInclRange, BuildInclBit,
75 BuildNulExpression,
76 BuildNot,
77 BuildRelOp,
78 BuildBinaryOp,
79 BuildUnaryOp,
80 RecordOp,
81 Top, DupFrame,
82 PopTF, PushTF, PopT, PushT, PopNothing, PopN, PushTFA,
83 PushTtok, PushTFtok, PopTFtok, PopTtok, PushTFAtok,
84 PushTFn, PushTFntok, PopTFn,
85 OperandT, OperandF, OperandA, OperandAnno, OperandTok,
86 DisplayStack, WriteOperand, Annotate,
87
88 BuildCodeOn, BuildCodeOff,
89 BuildProfileOn, BuildProfileOff,
90 BuildOptimizeOn, BuildOptimizeOff,
91 BuildAsm, BuildStmtNote, BuildLineNo, PushLineNo,
92 BuildConstructor,
93 BuildConstructorStart,
94 BuildConstructorEnd,
95 NextConstructorField, BuildTypeForConstructor,
96 PopConstructor,
97 BuildComponentValue,
98 SilentBuildConstructor, SilentBuildConstructorStart,
99
100 SetOptionOptimizing, SetOptionCoding, SetOptionProfiling,
101
102 QuadOperator,
103 Opposite,
104
105 IsReferenced,
106 IsBackReference,
107 IsUnConditional,
108 IsConditional, IsBackReferenceConditional,
109 IsGoto,
110 IsCall,
111 IsReturn,
112 IsProcedureScope,
113 IsNewLocalVar,
114 IsKillLocalVar,
115 IsCatchBegin,
116 IsCatchEnd,
117 IsInitStart,
118 IsInitEnd,
119 IsFinallyStart,
120 IsFinallyEnd,
121 IsCodeOn, (* Compiler flag testing routines *)
122 IsProfileOn,
123 IsOptimizeOn,
124 IsPseudoQuad,
125 IsDefOrModFile,
126 IsInitialisingConst, IsConstQuad, IsConditionalBooleanQuad,
127 IsQuadConstExpr,
128 IsBecomes,
129 IsDummy,
130 GetQuadOp1, GetQuadOp2, GetQuadOp3, GetQuadDest,
131 SetQuadConstExpr,
132
133 DumpQuadruples, DisplayQuadRange, DisplayQuad,
134 WriteOperator, BackPatchSubrangesAndOptParam,
135
136 GetQuad, GetFirstQuad, GetNextQuad, PutQuad,
137 SubQuad, EraseQuad, GetRealQuad,
138 GetQuadtok, GetQuadOtok, PutQuadOtok,
139 GetQuadOp, GetM2OperatorDesc,
140 GetQuadOTypetok,
141 CountQuads,
142 GetLastFileQuad,
143 GetLastQuadNo,
144 QuadToLineNo, QuadToTokenNo,
145 LoopAnalysis, ForLoopAnalysis,
146 AddVarientFieldToList, AddRecordToList,
147 AddVarientToList,
148 AddVarientRange, AddVarientEquality,
149 BeginVarient, EndVarient, ElseVarient,
150 BeginVarientList, EndVarientList,
151 IsAutoPushOn, PushAutoOn, PushAutoOff, PopAuto,
152 PushInConstExpression, PopInConstExpression,
153 IsInConstExpression,
154 PushInConstParameters, PopInConstParameters,
155 IsInConstParameters,
156 MustCheckOverflow, BuildAsmElement, BuildAsmTrash,
157 GetQuadTrash ;
158
159
160 TYPE
161 QuadOperator = (AddOp,
162 AddrOp,
163 ArithAddOp,
164 ArrayOp,
165 BecomesOp,
166 BuiltinConstOp,
167 BuiltinTypeInfoOp,
168 CallOp,
169 CastOp,
170 CatchBeginOp,
171 CatchEndOp,
172 CodeOffOp,
173 CodeOnOp,
174 CoerceOp,
175 ConvertOp,
176 DivCeilOp,
177 DivFloorOp,
178 DivM2Op,
179 DivTruncOp,
180 DummyOp,
181 ElementSizeOp,
182 EndFileOp,
183 ErrorOp,
184 ExclOp,
185 FinallyEndOp,
186 FinallyStartOp,
187 FunctValueOp,
188 GotoOp,
189 HighOp,
190 IfEquOp,
191 IfGreEquOp,
192 IfGreOp,
193 IfInOp,
194 IfLessEquOp,
195 IfLessOp,
196 IfNotEquOp,
197 IfNotInOp,
198 InclOp,
199 IndrXOp,
200 InitAddressOp,
201 InitEndOp,
202 InitStartOp,
203 InlineOp,
204 KillLocalVarOp,
205 LastForIteratorOp,
206 LineNumberOp,
207 LogicalAndOp,
208 LogicalDiffOp,
209 LogicalOrOp,
210 LogicalRotateOp,
211 LogicalShiftOp,
212 LogicalXorOp,
213 ModCeilOp,
214 ModFloorOp,
215 ModM2Op,
216 ModTruncOp,
217 ModuleScopeOp,
218 MultOp,
219 NegateOp,
220 NewLocalVarOp,
221 OptimizeOffOp,
222 OptimizeOnOp,
223 OptParamOp,
224 ParamOp,
225 ProcedureScopeOp,
226 ProfileOffOp,
227 ProfileOnOp,
228 RangeCheckOp,
229 RecordFieldOp,
230 RestoreExceptionOp,
231 RestorePriorityOp,
232 RetryOp,
233 ReturnOp,
234 ReturnValueOp,
235 SaveExceptionOp,
236 SavePriorityOp,
237 SizeOp,
238 StandardFunctionOp,
239 StartDefFileOp,
240 StartModFileOp,
241 StatementNoteOp,
242 SubOp,
243 SubrangeHighOp,
244 SubrangeLowOp,
245 StringConvertCnulOp,
246 StringConvertM2nulOp,
247 StringLengthOp,
248 ThrowOp,
249 TryOp,
250 UnboundedOp,
251 XIndrOp) ;
252
253
254 (*
255 SetOptionCoding - builds a code quadruple if the profiling
256 option was given to the compiler.
257 *)
258
259 PROCEDURE SetOptionCoding (b: BOOLEAN) ;
260
261
262 (*
263 SetOptionProfiling - builds a profile quadruple if the profiling
264 option was given to the compiler.
265 *)
266
267 PROCEDURE SetOptionProfiling (b: BOOLEAN) ;
268
269
270 (*
271 SetOptionOptimizing - builds a code quadruple if the profiling
272 option was given to the compiler.
273 *)
274
275 PROCEDURE SetOptionOptimizing (b: BOOLEAN) ;
276
277
278 (*
279 Opposite - returns the opposite comparison operator.
280 *)
281
282 PROCEDURE Opposite (Operator: QuadOperator) : QuadOperator ;
283
284
285 (*
286 IsReferenced - returns true if QuadNo is referenced by another quadruple.
287 *)
288
289 PROCEDURE IsReferenced (QuadNo: CARDINAL) : BOOLEAN ;
290
291
292 (*
293 IsBackReference - returns TRUE if quadruple, q, is referenced from a quad further on.
294 *)
295
296 PROCEDURE IsBackReference (q: CARDINAL) : BOOLEAN ;
297
298
299 (*
300 IsUnConditional - returns true if QuadNo is an unconditional jump.
301 *)
302
303 PROCEDURE IsUnConditional (QuadNo: CARDINAL) : BOOLEAN ;
304
305
306 (*
307 IsConditional - returns true if QuadNo is a conditional jump.
308 *)
309
310 PROCEDURE IsConditional (QuadNo: CARDINAL) : BOOLEAN ;
311
312
313 (*
314 IsBackReferenceConditional - returns TRUE if quadruple, q, is referenced from
315 a conditional quad further on.
316 *)
317
318 PROCEDURE IsBackReferenceConditional (q: CARDINAL) : BOOLEAN ;
319
320
321 (*
322 IsGoto - returns true if QuadNo is a goto operation.
323 *)
324
325 PROCEDURE IsGoto (QuadNo: CARDINAL) : BOOLEAN ;
326
327
328 (*
329 IsCall - returns true if QuadNo is a call operation.
330 *)
331
332 PROCEDURE IsCall (QuadNo: CARDINAL) : BOOLEAN ;
333
334
335 (*
336 IsReturn - returns true if QuadNo is a return operation.
337 *)
338
339 PROCEDURE IsReturn (QuadNo: CARDINAL) : BOOLEAN ;
340
341
342 (*
343 IsProcedureScope - returns true if QuadNo is a ProcedureScope operation.
344 *)
345
346 PROCEDURE IsProcedureScope (QuadNo: CARDINAL) : BOOLEAN ;
347
348
349 (*
350 IsNewLocalVar - returns true if QuadNo is a NewLocalVar operation.
351 *)
352
353 PROCEDURE IsNewLocalVar (QuadNo: CARDINAL) : BOOLEAN ;
354
355
356 (*
357 IsKillLocalVar - returns true if QuadNo is a KillLocalVar operation.
358 *)
359
360 PROCEDURE IsKillLocalVar (QuadNo: CARDINAL) : BOOLEAN ;
361
362
363 (*
364 IsCatchBegin - returns true if QuadNo is a catch begin quad.
365 *)
366
367 PROCEDURE IsCatchBegin (QuadNo: CARDINAL) : BOOLEAN ;
368
369
370 (*
371 IsCatchEnd - returns true if QuadNo is a catch end quad.
372 *)
373
374 PROCEDURE IsCatchEnd (QuadNo: CARDINAL) : BOOLEAN ;
375
376
377 (*
378 IsInitStart - returns true if QuadNo is a init start quad.
379 *)
380
381 PROCEDURE IsInitStart (QuadNo: CARDINAL) : BOOLEAN ;
382
383
384 (*
385 IsInitEnd - returns true if QuadNo is a init end quad.
386 *)
387
388 PROCEDURE IsInitEnd (QuadNo: CARDINAL) : BOOLEAN ;
389
390
391 (*
392 IsFinallyStart - returns true if QuadNo is a finally start quad.
393 *)
394
395 PROCEDURE IsFinallyStart (QuadNo: CARDINAL) : BOOLEAN ;
396
397
398 (*
399 IsFinallyEnd - returns true if QuadNo is a finally end quad.
400 *)
401
402 PROCEDURE IsFinallyEnd (QuadNo: CARDINAL) : BOOLEAN ;
403
404
405 (*
406 IsBecomes - return TRUE if QuadNo is a BecomesOp.
407 *)
408
409 PROCEDURE IsBecomes (QuadNo: CARDINAL) : BOOLEAN ;
410
411
412 (*
413 IsDummy - return TRUE if QuadNo is a DummyOp.
414 *)
415
416 PROCEDURE IsDummy (QuadNo: CARDINAL) : BOOLEAN ;
417
418
419 (*
420 IsQuadConstExpr - returns TRUE if QuadNo is part of a constant expression.
421 *)
422
423 PROCEDURE IsQuadConstExpr (QuadNo: CARDINAL) : BOOLEAN ;
424
425
426 (*
427 SetQuadConstExpr - sets the constexpr field to value.
428 *)
429
430 PROCEDURE SetQuadConstExpr (QuadNo: CARDINAL; value: BOOLEAN) ;
431
432
433 (*
434 GetQuadDest - returns the jump destination associated with quad.
435 *)
436
437 PROCEDURE GetQuadDest (QuadNo: CARDINAL) : CARDINAL ;
438
439
440 (*
441 GetQuadOp1 - returns the 1st operand associated with quad.
442 *)
443
444 PROCEDURE GetQuadOp1 (QuadNo: CARDINAL) : CARDINAL ;
445
446
447 (*
448 GetQuadOp2 - returns the 2nd operand associated with quad.
449 *)
450
451 PROCEDURE GetQuadOp2 (QuadNo: CARDINAL) : CARDINAL ;
452
453
454 (*
455 GetQuadOp3 - returns the 3rd operand associated with quad.
456 *)
457
458 PROCEDURE GetQuadOp3 (QuadNo: CARDINAL) : CARDINAL ;
459
460
461 (*
462 IsInitialisingConst - returns TRUE if the quadruple is setting
463 a const (op1) with a value.
464 *)
465
466 PROCEDURE IsInitialisingConst (QuadNo: CARDINAL) : BOOLEAN ;
467
468
469 (*
470 IsConstQuad - return TRUE if the quadruple is marked as a constexpr.
471 *)
472
473 PROCEDURE IsConstQuad (quad: CARDINAL) : BOOLEAN ;
474
475
476 (*
477 IsConditionalBooleanQuad - return TRUE if operand 1 is a boolean result.
478 *)
479
480 PROCEDURE IsConditionalBooleanQuad (quad: CARDINAL) : BOOLEAN ;
481
482
483 (*
484 IsOptimizeOn - returns true if the Optimize flag was true at QuadNo.
485 *)
486
487 PROCEDURE IsOptimizeOn (QuadNo: CARDINAL) : BOOLEAN ;
488
489
490 (*
491 IsProfileOn - returns true if the Profile flag was true at QuadNo.
492 *)
493
494 PROCEDURE IsProfileOn (QuadNo: CARDINAL) : BOOLEAN ;
495
496
497 (*
498 IsCodeOn - returns true if the Code flag was true at QuadNo.
499 *)
500
501 PROCEDURE IsCodeOn (QuadNo: CARDINAL) : BOOLEAN ;
502
503
504 (*
505 IsPseudoQuad - returns true if QuadNo is a compiler directive.
506 ie code, profile and optimize.
507 *)
508
509 PROCEDURE IsPseudoQuad (QuadNo: CARDINAL) : BOOLEAN ;
510
511
512 (*
513 IsDefOrModFile - returns TRUE if QuadNo is a start of Module or Def file
514 directive.
515 *)
516
517 PROCEDURE IsDefOrModFile (QuadNo: CARDINAL) : BOOLEAN ;
518
519
520 (*
521 DumpQuadruples - dump all quadruples providing the -fq, -fdump-lang-quad,
522 -fdump-lang-quad= or -fdump-lang-all were issued to the
523 command line.
524 *)
525
526 PROCEDURE DumpQuadruples (title: ARRAY OF CHAR) ;
527
528
529 (*
530 DisplayQuadRange - displays all quads in list range, start..end.
531 *)
532
533 PROCEDURE DisplayQuadRange (scope: CARDINAL; start, end: CARDINAL) ;
534
535
536 (*
537 DisplayQuad - displays a quadruple, QuadNo.
538 *)
539
540 PROCEDURE DisplayQuad (QuadNo: CARDINAL) ;
541
542
543 (*
544 GetLastFileQuad - returns the Quadruple number of the last StartDefFile or
545 StartModFile quadruple.
546 *)
547
548 PROCEDURE GetLastFileQuad (QuadNo: CARDINAL) : CARDINAL ;
549
550
551 (*
552 GetLastQuadNo - returns the last quadruple number referenced
553 by a GetQuad.
554 *)
555
556 PROCEDURE GetLastQuadNo () : CARDINAL ;
557
558
559 (*
560 QuadToTokenNo - Converts a QuadNo into the approprate token number of the
561 source file, the line number is returned.
562
563 This may be used to yield an idea where abouts in the
564 source file the code generetion is
565 processing.
566 *)
567
568 PROCEDURE QuadToTokenNo (QuadNo: CARDINAL) : CARDINAL ;
569
570
571 (*
572 QuadToLineNo - Converts a QuadNo into the approprate line number of the
573 source file, the line number is returned.
574
575 This may be used to yield an idea where abouts in the
576 source file the code generetion is
577 processing.
578 *)
579
580 PROCEDURE QuadToLineNo (QuadNo: CARDINAL) : CARDINAL ;
581
582
583 (*
584 GetQuad - returns the Quadruple QuadNo.
585 *)
586
587 PROCEDURE GetQuad (QuadNo: CARDINAL;
588 VAR Op: QuadOperator;
589 VAR Oper1, Oper2, Oper3: CARDINAL) ;
590
591
592 (*
593 GetQuadOp - returns the operator for quad.
594 *)
595
596 PROCEDURE GetQuadOp (quad: CARDINAL) : QuadOperator ;
597
598
599 (*
600 GetM2OperatorDesc - returns the Modula-2 string associated with the quad operator
601 (if possible). It returns NIL if no there is not an obvious match
602 in Modula-2. It is assummed that the string will be used during
603 construction of error messages and therefore keywords are
604 wrapped with a format specifier.
605 *)
606
607 PROCEDURE GetM2OperatorDesc (op: QuadOperator) : String ;
608
609
610 (*
611 GetQuadtok - returns the Quadruple QuadNo.
612 *)
613
614 PROCEDURE GetQuadtok (QuadNo: CARDINAL;
615 VAR Op: QuadOperator;
616 VAR Oper1, Oper2, Oper3: CARDINAL;
617 VAR Op1Pos, Op2Pos, Op3Pos: CARDINAL) ;
618
619
620 (*
621 GetQuadOtok - returns the Quadruple QuadNo.
622 *)
623
624 PROCEDURE GetQuadOtok (QuadNo: CARDINAL;
625 VAR tok: CARDINAL;
626 VAR Op: QuadOperator;
627 VAR Oper1, Oper2, Oper3: CARDINAL;
628 VAR overflowChecking, constExpr: BOOLEAN ;
629 VAR Op1Pos, Op2Pos, Op3Pos: CARDINAL) ;
630
631
632 (*
633 GetQuadOTypetok - returns the fields associated with quadruple QuadNo.
634 *)
635
636 PROCEDURE GetQuadOTypetok (QuadNo: CARDINAL;
637 VAR tok: CARDINAL;
638 VAR Op: QuadOperator;
639 VAR Oper1, Oper2, Oper3: CARDINAL;
640 VAR overflowChecking, typeChecking, constExpr: BOOLEAN ;
641 VAR Op1Pos, Op2Pos, Op3Pos: CARDINAL) ;
642
643
644 (*
645 PutQuadOtok - alters a quadruple QuadNo with Op, Oper1, Oper2, Oper3, and
646 sets a boolean to determinine whether overflow should be checked.
647 *)
648
649 PROCEDURE PutQuadOtok (QuadNo: CARDINAL;
650 tok: CARDINAL;
651 Op: QuadOperator;
652 Oper1, Oper2, Oper3: CARDINAL;
653 overflowChecking, constExpr: BOOLEAN ;
654 Op1Pos, Op2Pos, Op3Pos: CARDINAL) ;
655
656
657 (*
658 PutQuad - overwrites a quadruple QuadNo with Op, Oper1, Oper2, Oper3
659 *)
660
661 PROCEDURE PutQuad (QuadNo: CARDINAL;
662 Op: QuadOperator;
663 Oper1, Oper2, Oper3: CARDINAL) ;
664
665 (*
666 GetFirstQuad - returns the first quadruple.
667 *)
668
669 PROCEDURE GetFirstQuad () : CARDINAL ;
670
671
672 (*
673 GetNextQuad - returns the Quadruple number following QuadNo.
674 *)
675
676 PROCEDURE GetNextQuad (QuadNo: CARDINAL) : CARDINAL ;
677
678
679 (*
680 GetRealQuad - returns the Quadruple number of the real quadruple
681 at QuadNo or beyond.
682 *)
683
684 PROCEDURE GetRealQuad (QuadNo: CARDINAL) : CARDINAL ;
685
686
687 (*
688 SubQuad - removes quadruple QuadNo.
689 *)
690
691 PROCEDURE SubQuad (QuadNo: CARDINAL) ;
692
693
694 (*
695 EraseQuad - erases a quadruple QuadNo, the quaduple is still in the list
696 but wiped clean.
697 *)
698
699 PROCEDURE EraseQuad (QuadNo: CARDINAL) ;
700
701
702 (*
703 CountQuads - returns the number of quadruples.
704 *)
705
706 PROCEDURE CountQuads () : CARDINAL ;
707
708
709 (*
710 BuildScaffold - generate the main, init, finish functions if
711 no -c and this is the application module.
712 *)
713
714 PROCEDURE BuildScaffold (tok: CARDINAL; moduleSym: CARDINAL) ;
715
716
717 (*
718 StartBuildDefFile - generates a StartFileOp quadruple indicating the file
719 that has produced the subsequent quadruples.
720 The code generator uses the StartDefFileOp quadruples
721 to relate any error to the appropriate file.
722
723
724 Entry Exit
725 ===== ====
726
727
728 Ptr -> <- Ptr
729 +------------+ +------------+
730 | ModuleName | | ModuleName |
731 |------------| |------------|
732
733
734 Quadruples Produced
735
736 q StartDefFileOp _ _ ModuleSym
737 *)
738
739 PROCEDURE StartBuildDefFile (tok: CARDINAL) ;
740
741
742 (*
743 StartBuildModFile - generates a StartModFileOp quadruple indicating the file
744 that has produced the subsequent quadruples.
745 The code generator uses the StartModFileOp quadruples
746 to relate any error to the appropriate file.
747
748
749 Entry Exit
750 ===== ====
751
752
753 Ptr -> <- Ptr
754 +------------+ +------------+
755 | ModuleName | | ModuleName |
756 |------------| |------------|
757
758
759 Quadruples Produced
760
761 q StartModFileOp _ _ ModuleSym
762 *)
763
764 PROCEDURE StartBuildModFile (tok: CARDINAL) ;
765
766
767 (*
768 EndBuildFile - generates an EndFileOp quadruple indicating the file
769 that has produced the previous quadruples has ended.
770
771 Entry Exit
772 ===== ====
773
774
775 Ptr -> <- Ptr
776 +------------+ +------------+
777 | ModuleName | | ModuleName |
778 |------------| |------------|
779
780
781 Quadruples Produced
782
783 q EndFileOp _ _ ModuleSym
784 *)
785
786 PROCEDURE EndBuildFile (tok: CARDINAL) ;
787
788
789 (*
790 StartBuildInit - Builds the start initialisation code of a module.
791 *)
792
793 PROCEDURE StartBuildInit (tok: CARDINAL) ;
794
795
796 (*
797 EndBuildInit - Builds the end initialisation code of a module.
798 *)
799
800 PROCEDURE EndBuildInit (tok: CARDINAL) ;
801
802
803 (*
804 StartBuildFinally - Builds the start finalisation code of a module.
805 *)
806
807 PROCEDURE StartBuildFinally (tok: CARDINAL) ;
808
809
810 (*
811 EndBuildFinally - Builds the end finalisation code of a module.
812 *)
813
814 PROCEDURE EndBuildFinally (tok: CARDINAL) ;
815
816
817 (*
818 BuildExceptInitial - adds an ExceptOp quadruple in a modules
819 initial block.
820 *)
821
822 PROCEDURE BuildExceptInitial (tok: CARDINAL) ;
823
824
825 (*
826 BuildExceptFinally - adds an ExceptOp quadruple in a modules
827 finally block.
828 *)
829
830 PROCEDURE BuildExceptFinally (tok: CARDINAL) ;
831
832
833 (*
834 BuildExceptProcedure - adds an ExceptOp quadruple in a procedure
835 block.
836 *)
837
838 PROCEDURE BuildExceptProcedure (tok: CARDINAL) ;
839
840
841 (*
842 BuildRetry - adds an RetryOp quadruple.
843 *)
844
845 PROCEDURE BuildRetry (tok: CARDINAL) ;
846
847
848 (*
849 BuildReThrow - creates a ThrowOp _ _ NulSym, indicating that
850 the exception needs to be rethrown. The stack
851 is unaltered.
852 *)
853
854 PROCEDURE BuildReThrow (tokenno: CARDINAL) ;
855
856
857 (*
858 StartBuildInnerInit - Sets the start of initialization code of the
859 inner module to the next quadruple.
860 *)
861
862 PROCEDURE StartBuildInnerInit (tok: CARDINAL) ;
863
864
865 (*
866 EndBuildInnerInit - Sets the end initialization code of a module.
867 *)
868
869 PROCEDURE EndBuildInnerInit (tok: CARDINAL) ;
870
871
872 (*
873 BuildBuiltinConst - makes reference to a builtin constant within gm2.
874
875 Entry Exit
876
877 Ptr ->
878 +------------+ +------------+
879 | Ident | | Sym |
880 |------------| |------------|
881
882 Quadruple produced:
883
884 q Sym BuiltinConstOp Ident
885 *)
886
887 PROCEDURE BuildBuiltinConst ;
888
889
890 (*
891 BuildBuiltinTypeInfo - make reference to a builtin typeinfo function
892 within gm2.
893
894 Entry Exit
895
896 Ptr ->
897 +-------------+
898 | IdentType |
899 |-------------| +------------+
900 | ConstString | | Sym |
901 |-------------| |------------|
902
903 Quadruple produced:
904
905 q Sym BuiltinTypeInfoOp Ident ConstString
906 *)
907
908 PROCEDURE BuildBuiltinTypeInfo ;
909
910
911 (*
912 BuildAssignment - Builds an assignment from the values given on the
913 quad stack. Either an assignment to an
914 arithmetic expression or an assignment to a
915 boolean expression. This procedure should not
916 be called in CONST declarations.
917 The Stack is expected to contain:
918
919
920 Either
921
922 Entry Exit
923 ===== ====
924
925 Ptr ->
926 +------------+
927 | Expression |
928 |------------|
929 | Designator |
930 |------------| +------------+
931 | | | | <- Ptr
932 |------------| |------------|
933
934
935 Quadruples Produced
936
937 q BecomesOp Designator _ Expression
938
939 OR
940
941 Entry Exit
942 ===== ====
943
944 Ptr ->
945 +------------+
946 | True |False|
947 |------------|
948 | Designator |
949 |------------| +------------+
950 | | | | <- Ptr
951 |------------| |------------|
952
953
954 Quadruples Produced
955
956 q BecomesOp Designator _ TRUE
957 q+1 GotoOp q+3
958 q+2 BecomesOp Designator _ FALSE
959
960 *)
961
962 PROCEDURE BuildAssignment (becomesTokNo: CARDINAL) ;
963
964
965 (*
966 BuildAssignConstant - used to create constant in the CONST declaration.
967 The stack is expected to contain:
968
969 Either
970
971 Entry Exit
972 ===== ====
973
974 Ptr ->
975 +------------+
976 | Expression |
977 |------------|
978 | Designator |
979 |------------| +------------+
980 | | | | <- Ptr
981 |------------| |------------|
982
983
984 Quadruples Produced
985
986 q BecomesOp Designator _ Expression
987
988 OR
989
990 Entry Exit
991 ===== ====
992
993 Ptr ->
994 +------------+
995 | True |False|
996 |------------|
997 | Designator |
998 |------------| +------------+
999 | | | | <- Ptr
1000 |------------| |------------|
1001
1002
1003 Quadruples Produced
1004
1005 q BecomesOp Designator _ TRUE
1006 q+1 GotoOp q+3
1007 q+2 BecomesOp Designator _ FALSE
1008 *)
1009
1010 PROCEDURE BuildAssignConstant (equalsTokNo: CARDINAL) ;
1011
1012
1013 (*
1014 BuildAlignment - builds an assignment to an alignment constant.
1015
1016 The Stack is expected to contain:
1017
1018
1019 Entry Exit
1020 ===== ====
1021
1022 Ptr ->
1023 +---------------+
1024 | Expression |
1025 |---------------|
1026 | bytealignment |
1027 |---------------| empty
1028 *)
1029
1030 PROCEDURE BuildAlignment (tokno: CARDINAL) ;
1031
1032
1033 (*
1034 BuildBitLength - builds an assignment to a bit length constant.
1035
1036 The Stack is expected to contain:
1037
1038
1039 Entry Exit
1040 ===== ====
1041
1042 Ptr ->
1043 +------------+
1044 | Expression |
1045 |------------| empty
1046 *)
1047
1048 PROCEDURE BuildBitLength (tokno: CARDINAL) ;
1049
1050
1051 (*
1052 BuildPragmaField - builds an assignment to a pragma constant.
1053
1054 The Stack is expected to contain:
1055
1056
1057 Entry Exit
1058 ===== ====
1059
1060 Ptr ->
1061 +------------+
1062 | Expression |
1063 |------------| empty
1064 *)
1065
1066 PROCEDURE BuildPragmaField ;
1067
1068
1069 (*
1070 BuildDefaultFieldAlignment - builds an assignment to an alignment constant.
1071
1072 The Stack is expected to contain:
1073
1074
1075 Entry Exit
1076 ===== ====
1077
1078 Ptr ->
1079 +------------+
1080 | Expression |
1081 |------------| empty
1082 *)
1083
1084 PROCEDURE BuildDefaultFieldAlignment ;
1085
1086
1087 (*
1088 BuildRepeat - Builds the repeat statement from the quad stack.
1089 The Stack is expected to contain:
1090
1091
1092 Entry Exit
1093 ===== ====
1094
1095
1096 Empty
1097 <- Ptr
1098 +------------+
1099 | RepeatQuad |
1100 |------------|
1101
1102 *)
1103
1104 PROCEDURE BuildRepeat ;
1105
1106
1107 (*
1108 BuildUntil - Builds the until part of the repeat statement
1109 from the quad stack.
1110 The Stack is expected to contain:
1111
1112
1113 Entry Exit
1114 ===== ====
1115
1116 Ptr ->
1117 +------------+
1118 | t | f |
1119 |------------|
1120 | RepeatQuad | Empty
1121 |------------|
1122 *)
1123
1124 PROCEDURE BuildUntil ;
1125
1126
1127 (*
1128 BuildWhile - Builds the While part of the While statement
1129 from the quad stack.
1130 The Stack is expected to contain:
1131
1132
1133 Entry Exit
1134 ===== ====
1135
1136 <- Ptr
1137 |------------|
1138 Empty | WhileQuad |
1139 |------------|
1140 *)
1141
1142 PROCEDURE BuildWhile ;
1143
1144
1145 (*
1146 BuildDoWhile - Builds the Do part of the while statement
1147 from the quad stack.
1148 The Stack is expected to contain:
1149
1150
1151 Entry Exit
1152 ===== ====
1153
1154 Ptr ->
1155 +------------+ +------------+
1156 | t | f | | 0 | f |
1157 |------------| |------------|
1158 | WhileQuad | | WhileQuad |
1159 |------------| |------------|
1160
1161 Quadruples
1162
1163 BackPatch t exit to the NextQuad
1164 *)
1165
1166 PROCEDURE BuildDoWhile ;
1167
1168
1169 (*
1170 BuildEndWhile - Builds the end part of the while statement
1171 from the quad stack.
1172 The Stack is expected to contain:
1173
1174
1175 Entry Exit
1176 ===== ====
1177
1178 Ptr ->
1179 +------------+
1180 | t | f |
1181 |------------|
1182 | WhileQuad | Empty
1183 |------------|
1184
1185 Quadruples
1186
1187 q GotoOp WhileQuad
1188 False exit is backpatched with q+1
1189 *)
1190
1191 PROCEDURE BuildEndWhile (reltokpos: INTEGER) ;
1192
1193
1194 (*
1195 BuildLoop - Builds the Loop part of the Loop statement
1196 from the quad stack.
1197 The Stack is expected to contain:
1198
1199
1200 Entry Exit
1201 ===== ====
1202
1203 <- Ptr
1204 Empty +------------+
1205 | LoopQuad |
1206 |------------|
1207 *)
1208
1209 PROCEDURE BuildLoop ;
1210
1211
1212 (*
1213 BuildExit - Builds the Exit part of the Loop statement.
1214 *)
1215
1216 PROCEDURE BuildExit ;
1217
1218
1219 (*
1220 BuildEndLoop - Builds the End part of the Loop statement
1221 from the quad stack.
1222 The Stack is expected to contain:
1223
1224
1225 Entry Exit
1226 ===== ====
1227
1228 Ptr ->
1229 +------------+
1230 | LoopQuad | Empty
1231 |------------|
1232
1233 Quadruples
1234
1235 Goto _ _ LoopQuad
1236 *)
1237
1238 PROCEDURE BuildEndLoop ;
1239
1240
1241 (*
1242 BuildThenIf - Builds the Then part of the If statement
1243 from the quad stack.
1244 The Stack is expected to contain:
1245
1246
1247 Entry Exit
1248 ===== ====
1249
1250 Ptr -> <- Ptr
1251 +------------+ +------------+
1252 | t | f | | 0 | f |
1253 |------------| |------------|
1254
1255 Quadruples
1256
1257 The true exit is BackPatched to point to
1258 the NextQuad.
1259 *)
1260
1261 PROCEDURE BuildThenIf ;
1262
1263
1264 (*
1265 BuildElse - Builds the Else part of the If statement
1266 from the quad stack.
1267 The Stack is expected to contain:
1268
1269
1270 Entry Exit
1271 ===== ====
1272
1273 Ptr ->
1274 +------------+ +------------+
1275 | t | f | | t+q | 0 |
1276 |------------| |------------|
1277
1278 Quadruples
1279
1280 q GotoOp _ _ 0
1281 q+1 <- BackPatched from f
1282 *)
1283
1284 PROCEDURE BuildElse ;
1285
1286
1287 (*
1288 BuildEndIf - Builds the End part of the If statement
1289 from the quad stack.
1290 The Stack is expected to contain:
1291
1292
1293 Entry Exit
1294 ===== ====
1295
1296 Ptr ->
1297 +------------+
1298 | t | f | Empty
1299 |------------|
1300
1301 Quadruples
1302
1303 Both t and f are backpatched to point to the NextQuad
1304 *)
1305
1306 PROCEDURE BuildEndIf ;
1307
1308
1309 (*
1310 BuildElsif1 - Builds the Elsif part of the If statement
1311 from the quad stack.
1312 The Stack is expected to contain:
1313
1314
1315 Entry Exit
1316 ===== ====
1317
1318 Ptr ->
1319 +------------+ +------------+
1320 | t | f | | t+q | 0 |
1321 |------------| |------------|
1322
1323 Quadruples
1324
1325 q GotoOp _ _ 0
1326 q+1 <- BackPatched from f
1327 *)
1328
1329 PROCEDURE BuildElsif1 ;
1330
1331
1332 (*
1333 BuildElsif2 - Builds the Elsif until part of the If statement
1334 from the quad stack.
1335 The Stack is expected to contain:
1336
1337
1338 Entry Exit
1339 ===== ====
1340
1341 Ptr ->
1342 +--------------+
1343 | 0 | f1 | <- Ptr
1344 |--------------| +---------------+
1345 | t2 | f2 | | t2 | f1+f2 |
1346 |--------------| |---------------|
1347 *)
1348
1349 PROCEDURE BuildElsif2 ;
1350
1351
1352 (*
1353 BuildForToByDo - Builds the For To By Do part of the For statement
1354 from the quad stack.
1355 The Stack is expected to contain:
1356
1357
1358 Entry Exit
1359 ===== ====
1360
1361
1362 Ptr -> <- Ptr
1363 +------------+ +------------+
1364 | BySym | | t | f |
1365 |------------| |------------|
1366 | e2 | | ForQuad |
1367 |------------| |------------|
1368 | e1 | | BySym |
1369 |------------| |------------|
1370 | Ident | | IdentSym |
1371 |------------| |------------|
1372
1373 Quadruple
1374
1375 q BecomesOp IdentSym _ e1
1376 q+1 if < by 0 q+5
1377 q+2 GotoOp q+3
1378 q+3 If > IdentSym e2 _
1379 q+4 GotoOp q+7
1380 q+5 If <= IdentSym e2 _
1381 q+6 GotoOp q+7
1382
1383
1384 The For Loop is regarded:
1385
1386 For ident := e1 To e2 By by Do
1387
1388 End
1389 *)
1390
1391 PROCEDURE BuildForToByDo ;
1392
1393
1394 (*
1395 BuildPseudoBy - Builds the Non existant part of the By
1396 clause of the For statement
1397 from the quad stack.
1398 The Stack is expected to contain:
1399
1400
1401 Entry Exit
1402 ===== ====
1403
1404 <- Ptr
1405 +------------+
1406 Empty | BySym |
1407 |------------|
1408 *)
1409
1410 PROCEDURE BuildPseudoBy ;
1411
1412
1413 (*
1414 BuildEndFor - Builds the End part of the For statement
1415 from the quad stack.
1416 The Stack is expected to contain:
1417
1418
1419 Entry Exit
1420 ===== ====
1421
1422 Ptr ->
1423 +------------+
1424 | t | f |
1425 |------------|
1426 | ForQuad |
1427 |------------|
1428 | BySym |
1429 |------------|
1430 | IdSym | Empty
1431 |------------|
1432 *)
1433
1434 PROCEDURE BuildEndFor (endpostok: CARDINAL) ;
1435
1436
1437 (*
1438 BuildCaseStart - starts the case statement.
1439 It initializes a backpatch list on the compile
1440 time stack, the list is used to contain all
1441 case break points. The list is later backpatched
1442 and contains all positions of the case statement
1443 which jump to the end of the case statement.
1444 The stack also contains room for a boolean
1445 expression, this is needed to allow , operator
1446 in the CaseField alternatives.
1447
1448 The Stack is expected to contain:
1449
1450
1451 Entry Exit
1452 ===== ====
1453
1454 <- Ptr
1455 +------------+
1456 Empty | 0 | 0 |
1457 |------------|
1458 | 0 | 0 |
1459 |------------|
1460 *)
1461
1462 PROCEDURE BuildCaseStart ;
1463
1464
1465 (*
1466 BuildCaseStartStatementSequence - starts the statement sequence
1467 inside a case clause.
1468 BackPatches the true exit to the
1469 NextQuad.
1470 The Stack:
1471
1472 Entry Exit
1473
1474 Ptr -> <- Ptr
1475 +-----------+ +------------+
1476 | t | f | | 0 | f |
1477 |-----------| |------------|
1478 *)
1479
1480 PROCEDURE BuildCaseStartStatementSequence ;
1481
1482
1483 (*
1484 BuildCaseEndStatementSequence - ends the statement sequence
1485 inside a case clause.
1486 BackPatches the false exit f1 to the
1487 NextQuad.
1488 Asserts that t1 and f2 is 0
1489 Pushes t2+q and 0
1490
1491 Quadruples:
1492
1493 q GotoOp _ _ 0
1494
1495 The Stack:
1496
1497 Entry Exit
1498
1499 Ptr -> <- Ptr
1500 +-----------+ +------------+
1501 | t1 | f1 | | 0 | 0 |
1502 |-----------| |------------|
1503 | t2 | f2 | | t2+q | 0 |
1504 |-----------| |------------|
1505 *)
1506
1507 PROCEDURE BuildCaseEndStatementSequence ;
1508
1509
1510 (*
1511 BuildCaseRange - builds the range testing quaruples for
1512 a case clause.
1513
1514 IF (e1>=ce1) AND (e1<=ce2)
1515 THEN
1516
1517 ELS..
1518
1519 The Stack:
1520
1521 Entry Exit
1522
1523 Ptr ->
1524 +-----------+
1525 | ce2 | <- Ptr
1526 |-----------| +-----------+
1527 | ce1 | | t | f |
1528 |-----------| |-----------|
1529 | t1 | f1 | | t1 | f1 |
1530 |-----------| |-----------|
1531 | t2 | f2 | | t2 | f2 |
1532 |-----------| |-----------|
1533 | e1 | | e1 |
1534 |-----------| |-----------|
1535 *)
1536
1537 PROCEDURE BuildCaseRange ;
1538
1539
1540 (*
1541 BuildCaseEquality - builds the range testing quadruples for
1542 a case clause.
1543
1544 IF e1=ce1
1545 THEN
1546
1547 ELS..
1548
1549 The Stack:
1550
1551 Entry Exit
1552
1553 Ptr ->
1554 +-----------+ +-----------+
1555 | ce1 | | t | f |
1556 |-----------| |-----------|
1557 | t1 | f1 | | t1 | f1 |
1558 |-----------| |-----------|
1559 | t2 | f2 | | t2 | f2 |
1560 |-----------| |-----------|
1561 | e1 | | e1 |
1562 |-----------| |-----------|
1563 *)
1564
1565 PROCEDURE BuildCaseEquality ;
1566
1567
1568 (*
1569 BuildCaseList - merges two case tests into one
1570
1571 The Stack:
1572
1573 Entry Exit
1574
1575 Ptr ->
1576 +-----------+
1577 | t2 | f2 |
1578 |-----------| +-------------+
1579 | t1 | f1 | | t1+t2| f1+f2|
1580 |-----------| |-------------|
1581 *)
1582
1583 PROCEDURE BuildCaseList ;
1584
1585
1586 (*
1587 BuildCaseOr - builds the , in the case clause.
1588
1589 The Stack:
1590
1591 Entry Exit
1592
1593 Ptr -> <- Ptr
1594 +-----------+ +------------+
1595 | t | f | | t | 0 |
1596 |-----------| |------------|
1597 *)
1598
1599 PROCEDURE BuildCaseOr ;
1600
1601
1602 (*
1603 BuildCaseElse - builds the else of case clause.
1604
1605 The Stack:
1606
1607 Entry Exit
1608
1609 Ptr -> <- Ptr
1610 +-----------+ +------------+
1611 | t | f | | t | 0 |
1612 |-----------| |------------|
1613 *)
1614
1615 PROCEDURE BuildCaseElse ;
1616
1617
1618 (*
1619 BuildCaseEnd - builds the end of case clause.
1620
1621 The Stack:
1622
1623 Entry Exit
1624
1625 Ptr ->
1626 +-----------+
1627 | t1 | f1 |
1628 |-----------|
1629 | t2 | f2 |
1630 |-----------|
1631 | e1 |
1632 |-----------| Empty
1633 *)
1634
1635 PROCEDURE BuildCaseEnd ;
1636
1637
1638 (*
1639 BuildCaseCheck - builds the case checking code to ensure that
1640 the program does not need an else clause at runtime.
1641 The stack is unaltered.
1642 *)
1643
1644 PROCEDURE BuildCaseCheck ;
1645
1646
1647 (*
1648 BuildNulParam - Builds a nul parameter on the stack.
1649 The Stack:
1650
1651 Entry Exit
1652
1653 <- Ptr
1654 Empty +------------+
1655 | 0 |
1656 |------------|
1657 *)
1658
1659 PROCEDURE BuildNulParam ;
1660
1661
1662 (*
1663 BuildProcedureCall - builds a procedure call.
1664 The Stack:
1665
1666
1667 Entry Exit
1668
1669 Ptr ->
1670 +----------------+
1671 | NoOfParam |
1672 |----------------|
1673 | Param 1 |
1674 |----------------|
1675 | Param 2 |
1676 |----------------|
1677 . .
1678 . .
1679 . .
1680 |----------------|
1681 | Param # |
1682 |----------------|
1683 | ProcSym | Type | Empty
1684 |----------------|
1685 *)
1686
1687 PROCEDURE BuildProcedureCall (tokno: CARDINAL) ;
1688
1689
1690 (*
1691 CheckBuildFunction - checks to see whether ProcSym is a function
1692 and if so it adds a TempSym value which will
1693 hold the return value once the function finishes.
1694 This procedure also generates an error message
1695 if the user is calling a function and ignoring
1696 the return result. The additional TempSym
1697 is not created if ProcSym is a procedure
1698 and the stack is unaltered.
1699
1700 The Stack:
1701
1702
1703 Entry Exit
1704
1705 Ptr ->
1706
1707 +----------------+
1708 | ProcSym | Type |
1709 +----------------+ |----------------|
1710 | ProcSym | Type | | TempSym | Type |
1711 |----------------| |----------------|
1712 *)
1713
1714 PROCEDURE CheckBuildFunction () : BOOLEAN ;
1715
1716
1717 (*
1718 BuildFunctionCall - builds a function call.
1719 The Stack:
1720
1721
1722 Entry Exit
1723
1724 Ptr ->
1725 +----------------+
1726 | NoOfParam |
1727 |----------------|
1728 | Param 1 |
1729 |----------------|
1730 | Param 2 |
1731 |----------------|
1732 . .
1733 . .
1734 . .
1735 |----------------|
1736 | Param # | <- Ptr
1737 |----------------| +------------+
1738 | ProcSym | Type | | ReturnVar |
1739 |----------------| |------------|
1740
1741 *)
1742
1743 PROCEDURE BuildFunctionCall (ConstExpr: BOOLEAN) ;
1744
1745
1746 (*
1747 BuildConstFunctionCall - builds a function call and checks that this function can be
1748 called inside a ConstExpression.
1749
1750 The Stack:
1751
1752
1753 Entry Exit
1754
1755 Ptr ->
1756 +----------------+
1757 | NoOfParam |
1758 |----------------|
1759 | Param 1 |
1760 |----------------|
1761 | Param 2 |
1762 |----------------|
1763 . .
1764 . .
1765 . .
1766 |----------------|
1767 | Param # | <- Ptr
1768 |----------------| +------------+
1769 | ProcSym | Type | | ReturnVar |
1770 |----------------| |------------|
1771
1772 *)
1773
1774 PROCEDURE BuildConstFunctionCall ;
1775
1776
1777 (*
1778 BuildBooleanVariable - tests to see whether top of stack is a boolean
1779 conditional and if so it converts it into a boolean
1780 variable.
1781 *)
1782
1783 PROCEDURE BuildBooleanVariable ;
1784
1785
1786 (*
1787 BuildModuleStart - starts current module scope.
1788 *)
1789
1790 PROCEDURE BuildModuleStart (tok: CARDINAL) ;
1791
1792
1793 (*
1794 BuildProcedureStart - Builds start of the procedure. Creates space for
1795 the local variables.
1796 The Stack is expected to contain:
1797
1798
1799 Entry Exit
1800 ===== ====
1801
1802 Ptr -> <- Ptr
1803 +------------+ +-----------+
1804 | ProcSym | | ProcSym |
1805 |------------| |-----------|
1806 | Name | | Name |
1807 |------------| |-----------|
1808
1809
1810 Quadruples:
1811
1812 q NewLocalVarOp _ _ ProcSym
1813 *)
1814
1815 PROCEDURE BuildProcedureStart ;
1816
1817
1818 (*
1819 BuildProcedureBegin - determines the start of the BEGIN END block of
1820 the procedure.
1821 The Stack is expected to contain:
1822
1823
1824 Entry Exit
1825 ===== ====
1826
1827 Ptr -> <- Ptr
1828 +------------+ +-----------+
1829 | ProcSym | | ProcSym |
1830 |------------| |-----------|
1831 | Name | | Name |
1832 |------------| |-----------|
1833
1834
1835 Quadruples:
1836
1837 q BeginOp _ _ ProcSym
1838 *)
1839
1840 PROCEDURE BuildProcedureBegin ;
1841
1842
1843 (*
1844 BuildProcedureEnd - Builds end of the procedure. Destroys space for
1845 the local variables.
1846 The Stack is expected to contain:
1847
1848
1849 Entry Exit
1850 ===== ====
1851
1852 Ptr -> <- Ptr
1853 +------------+ +-----------+
1854 | ProcSym | | ProcSym |
1855 |------------| |-----------|
1856 | Name | | Name |
1857 |------------| |-----------|
1858
1859
1860 Quadruples:
1861
1862 q KillLocalVarOp _ _ ProcSym
1863 *)
1864
1865 PROCEDURE BuildProcedureEnd ;
1866
1867
1868 (*
1869 BuildReturn - Builds the Return part of the procedure.
1870 The Stack is expected to contain:
1871
1872
1873 Entry Exit
1874 ===== ====
1875
1876 Ptr ->
1877 +------------+
1878 | e1 | Empty
1879 |------------|
1880 *)
1881
1882 PROCEDURE BuildReturn (tokreturn: CARDINAL) ;
1883
1884
1885 (*
1886 BuildModulePriority - assigns the current module with a priority
1887 from the top of stack.
1888
1889 Entry Exit
1890 ===== ====
1891
1892
1893 Ptr -> Empty
1894 +------------+
1895 | Priority |
1896 |------------|
1897 *)
1898
1899 PROCEDURE BuildModulePriority ;
1900
1901
1902 (*
1903 StartBuildWith - performs the with statement.
1904 The Stack:
1905
1906 Entry Exit
1907
1908 +------------+
1909 | Sym | Type | Empty
1910 |------------|
1911 *)
1912
1913 PROCEDURE StartBuildWith (withTok: CARDINAL) ;
1914
1915
1916 (*
1917 EndBuildWith - terminates the innermost with scope.
1918 *)
1919
1920 PROCEDURE EndBuildWith ;
1921
1922
1923 (*
1924 CheckWithReference - performs the with statement.
1925 The Stack:
1926
1927 Entry Exit
1928
1929 +------------+ +------------+
1930 | Sym | Type | | Sym | Type |
1931 |------------| |------------|
1932 *)
1933
1934 PROCEDURE CheckWithReference ;
1935
1936
1937 (*
1938 BuildDesignatorRecord - Builds the record referencing.
1939 The Stack is expected to contain:
1940
1941
1942 Entry Exit
1943 ===== ====
1944
1945 Ptr ->
1946 +--------------+
1947 | n |
1948 |--------------|
1949 | fld1 | type1 |
1950 |--------------|
1951 . .
1952 . .
1953 . .
1954 |--------------|
1955 | fldn | typen | <- Ptr
1956 |--------------| +-------------+
1957 | Sym | Type | | S | type1|
1958 |--------------| |-------------|
1959 *)
1960
1961 PROCEDURE BuildDesignatorRecord (dottok: CARDINAL) ;
1962
1963
1964 (*
1965 BuildDesignatorArray - Builds the array referencing.
1966 The Stack is expected to contain:
1967
1968
1969 Entry Exit
1970 ===== ====
1971
1972 Ptr ->
1973 +--------------+
1974 | n | Empty
1975 |--------------|
1976 | e1 |
1977 |--------------|
1978 . .
1979 . .
1980 . .
1981 |--------------|
1982 | e2 | <- Ptr
1983 |--------------| +------------+
1984 | Sym | Type | | S | T |
1985 |--------------| |------------|
1986 *)
1987
1988 PROCEDURE BuildDesignatorArray ;
1989
1990
1991 (*
1992 BuildDesignatorPointer - Builds the record referencing.
1993 The Stack is expected to contain:
1994
1995
1996 Entry Exit
1997 ===== ====
1998
1999 Ptr -> <- Ptr
2000 +--------------+ +--------------+
2001 | Sym1 | Type1| | Sym2 | Type2|
2002 |--------------| |--------------|
2003 *)
2004
2005 PROCEDURE BuildDesignatorPointer (ptrtok: CARDINAL) ;
2006
2007
2008 (*
2009 BuildNulExpression - Builds a nul expression on the stack.
2010 The Stack:
2011
2012 Entry Exit
2013
2014 <- Ptr
2015 Empty +------------+
2016 | NulSym |
2017 |------------|
2018 tokpos is the position of the RETURN token.
2019 *)
2020
2021 PROCEDURE BuildNulExpression (tokpos: CARDINAL) ;
2022
2023
2024 (*
2025 BuildSetStart - Pushes a Bitset type on the stack.
2026
2027 The Stack:
2028
2029 Entry Exit
2030
2031 Ptr -> <- Ptr
2032
2033 Empty +--------------+
2034 | Bitset |
2035 |--------------|
2036 *)
2037
2038 PROCEDURE BuildSetStart (tokpos: CARDINAL) ;
2039
2040
2041 (*
2042 BuildSetEnd - pops the set value and type from the stack
2043 and pushes the value,type pair.
2044
2045 Entry Exit
2046
2047 Ptr ->
2048 +--------------+
2049 | Set Value | <- Ptr
2050 |--------------| +--------------+
2051 | Set Type | | Value | Type |
2052 |--------------| |--------------|
2053 *)
2054
2055 PROCEDURE BuildSetEnd ;
2056
2057
2058 (*
2059 BuildEmptySet - Builds an empty set on the stack.
2060 The Stack:
2061
2062 Entry Exit
2063
2064 <- Ptr
2065 +-------------+
2066 Ptr -> | Value |
2067 +-----------+ |-------------|
2068 | SetType | | SetType |
2069 |-----------| |-------------|
2070
2071 tokpos points to the opening '{'.
2072 *)
2073
2074 PROCEDURE BuildEmptySet (tokpos: CARDINAL) ;
2075
2076
2077 (*
2078 BuildInclRange - includes a set range with a set.
2079
2080
2081 Entry Exit
2082 ===== ====
2083
2084
2085 Ptr ->
2086 +------------+
2087 | El2 |
2088 |------------|
2089 | El1 | <- Ptr
2090 |------------| +-------------------+
2091 | Set Value | | Value + {El1..El2}|
2092 |------------| |-------------------|
2093 | Set Type | | Set Type |
2094 |------------| |-------------------|
2095
2096 No quadruples produced as the range info is contained within
2097 the set value.
2098 *)
2099
2100 PROCEDURE BuildInclRange ;
2101
2102
2103 (*
2104 BuildInclBit - includes a bit into the set.
2105
2106 Entry Exit
2107 ===== ====
2108
2109
2110 Ptr ->
2111 +------------+
2112 | Element | <- Ptr
2113 |------------| +------------+
2114 | Value | | Value |
2115 |------------| |------------|
2116 | Type | | Type |
2117 |------------| |------------|
2118
2119 No quadruples produced as this bit inclusion is contained within
2120 the set value.
2121 *)
2122
2123 PROCEDURE BuildInclBit ;
2124
2125
2126 (*
2127 SilentBuildConstructor - places NulSym into the constructor fifo queue.
2128 *)
2129
2130 PROCEDURE SilentBuildConstructor ;
2131
2132
2133 (*
2134 SilentBuildConstructorStart - removes an entry from the constructor fifo queue.
2135 *)
2136
2137 PROCEDURE SilentBuildConstructorStart ;
2138
2139
2140 (*
2141 BuildConstructor - builds a constructor.
2142 Stack
2143
2144 Entry Exit
2145
2146 Ptr ->
2147 +------------+
2148 | Type | <- Ptr
2149 |------------+
2150 *)
2151
2152 PROCEDURE BuildConstructor (tokcbrpos: CARDINAL) ;
2153
2154
2155 (*
2156 BuildConstructorStart - builds a constructor.
2157 Stack
2158
2159 Entry Exit
2160
2161 Ptr -> <- Ptr
2162 +------------+ +------------+
2163 | Name | | Sym |
2164 |------------+ |------------|
2165 *)
2166
2167 PROCEDURE BuildConstructorStart (cbratokpos: CARDINAL) ;
2168
2169
2170 (*
2171 BuildConstructorEnd - removes the current constructor frame from the
2172 constructor stack (it does not effect the quad
2173 stack)
2174
2175 Stack
2176
2177 Entry Exit
2178
2179 Ptr -> <- Ptr
2180 +------------+ +------------+
2181 | const | | const |
2182 |------------+ |------------|
2183
2184 startpos is the start of the constructor, either the typename or '{'
2185 cbratokpos is the '}'.
2186 *)
2187
2188 PROCEDURE BuildConstructorEnd (startpos, cbratokpos: CARDINAL) ;
2189
2190
2191 (*
2192 NextConstructorField - increments the top of constructor stacks
2193 index by one.
2194 *)
2195
2196 PROCEDURE NextConstructorField ;
2197
2198
2199 (*
2200 BuildTypeForConstructor - pushes the type implied by the current constructor.
2201 If no constructor is currently being built then
2202 it Pushes a Bitset type.
2203 *)
2204
2205 PROCEDURE BuildTypeForConstructor (tokpos: CARDINAL) ;
2206
2207
2208 (*
2209 BuildComponentValue - builds a component value.
2210
2211 Entry Exit
2212
2213 Ptr -> <- Ptr
2214
2215
2216 +------------+ +------------+
2217 | const | | const |
2218 |------------| |------------|
2219
2220 (this is incomplete (fixme))
2221 *)
2222
2223 PROCEDURE BuildComponentValue ;
2224
2225
2226 (*
2227 PopConstructor - removes the top constructor from the top of stack.
2228 *)
2229
2230 PROCEDURE PopConstructor ;
2231
2232
2233 (*
2234 BuildNot - Builds a NOT operation from the quad stack.
2235 The Stack is expected to contain:
2236
2237
2238 Entry Exit
2239 ===== ====
2240
2241 Ptr -> <- Ptr
2242 +------------+ +------------+
2243 | t | f | | f | t |
2244 |------------| |------------|
2245 *)
2246
2247 PROCEDURE BuildNot (notTokPos: CARDINAL) ;
2248
2249
2250 (*
2251 RecordOp - Records the operator passed on the stack.
2252 Checks for AND operator or OR operator
2253 if either of these operators are found then BackPatching
2254 takes place.
2255 The Expected Stack:
2256
2257 Entry Exit
2258
2259 Ptr -> <- Ptr
2260 +-------------+ +-------------+
2261 | OperatorTok | | OperatorTok |
2262 |-------------| |-------------|
2263 | t | f | | t | f |
2264 |-------------| |-------------|
2265
2266
2267 If OperatorTok=AndTok
2268 Then
2269 BackPatch(f, NextQuad)
2270 Elsif OperatorTok=OrTok
2271 Then
2272 BackPatch(t, NextQuad)
2273 End
2274 *)
2275
2276 PROCEDURE RecordOp ;
2277
2278
2279 (*
2280 BuildRelOp - Builds a relative operation from the quad stack.
2281 The Stack is expected to contain:
2282
2283
2284 Entry Exit
2285 ===== ====
2286
2287 Ptr ->
2288 +------------+
2289 | e1 |
2290 |------------| <- Ptr
2291 | Operator |
2292 |------------| +------------+
2293 | e2 | | t | f |
2294 |------------| |------------|
2295
2296
2297 Quadruples Produced
2298
2299 q IFOperator e1 e2 TrueExit
2300 q+1 GotoOp FalseExit
2301 *)
2302
2303 PROCEDURE BuildRelOp (optokpos: CARDINAL) ;
2304
2305
2306 (*
2307 BuildBinaryOp - Builds a binary operation from the quad stack.
2308 The Stack is expected to contain:
2309
2310
2311 Entry Exit
2312 ===== ====
2313
2314 Ptr ->
2315 +------------+
2316 | Sym1 |
2317 |------------|
2318 | Operator | <- Ptr
2319 |------------| +------------+
2320 | Sym2 | | Temporary |
2321 |------------| |------------|
2322
2323
2324 Quadruples Produced
2325
2326 q Operator Temporary Sym1 Sym2
2327
2328 *)
2329
2330 PROCEDURE BuildBinaryOp ;
2331
2332
2333 (*
2334 BuildUnaryOp - Builds a unary operation from the quad stack.
2335 The Stack is expected to contain:
2336
2337
2338 Entry Exit
2339 ===== ====
2340
2341 Ptr ->
2342 +------------+
2343 | Sym1 |
2344 |------------| +------------+
2345 | Operator | | Temporary | <- Ptr
2346 |------------| |------------|
2347
2348
2349 Quadruples Produced
2350
2351 q Operator Temporary _ Sym1
2352
2353 *)
2354
2355 PROCEDURE BuildUnaryOp ;
2356
2357
2358 (*
2359 OperandT - returns the ident operand stored in the true position on the boolean stack.
2360 *)
2361
2362 PROCEDURE OperandT (pos: CARDINAL) : WORD ;
2363
2364
2365 (*
2366 OperandF - returns the ident operand stored in the false position on the boolean stack.
2367 *)
2368
2369 PROCEDURE OperandF (pos: CARDINAL) : WORD ;
2370
2371
2372 (*
2373 PushTF - Push a True and a False exit quad numbers onto the
2374 True/False stack.
2375 *)
2376
2377 PROCEDURE PushTF (True, False: WORD) ;
2378
2379
2380 (*
2381 PopTF - Pops a True and a False exit quad numbers from the
2382 True/False stack.
2383 *)
2384
2385 PROCEDURE PopTF (VAR True, False: WORD) ;
2386
2387
2388 (*
2389 PushT - Push a True exit quad numbers onto the
2390 True/False stack. The False exit will be zero.
2391 *)
2392
2393 PROCEDURE PushT (True: WORD) ;
2394
2395
2396 (*
2397 PopT - Pop a True exit quad number from the True/False
2398 stack. The False exit is ignored.
2399 *)
2400
2401 PROCEDURE PopT (VAR True: WORD) ;
2402
2403
2404 (*
2405 PushTtok - Push an item onto the stack in the T (true) position,
2406 it is assummed to be a token and its token location is recorded.
2407 *)
2408
2409 PROCEDURE PushTtok (True: WORD; tokno: CARDINAL) ;
2410
2411
2412 (*
2413 PushTFtok - Push an item onto the stack in the T (true) position,
2414 it is assummed to be a token and its token location is recorded.
2415 *)
2416
2417 PROCEDURE PushTFtok (True, False: WORD; tokno: CARDINAL) ;
2418
2419
2420 (*
2421 PopTFtok - Pop T/F/tok from the stack.
2422 *)
2423
2424 PROCEDURE PopTFtok (VAR True, False: WORD; VAR tokno: CARDINAL) ;
2425
2426
2427 (*
2428 PushTFAtok - Push T/F/A/tok to the stack.
2429 *)
2430
2431 PROCEDURE PushTFAtok (True, False, Array: WORD; tokno: CARDINAL) ;
2432
2433
2434 (*
2435 PopTtok - Pops the T value from the stack and token position.
2436 *)
2437
2438 PROCEDURE PopTtok (VAR True: WORD; VAR tok: CARDINAL) ;
2439
2440
2441 (*
2442 PushTFn - Push a True and False numbers onto the True/False stack.
2443 True and False are assumed to contain Symbols or Ident etc.
2444 *)
2445
2446 PROCEDURE PushTFn (True, False, n: WORD) ;
2447
2448
2449 (*
2450 PushTFntok - Push a True and False numbers onto the True/False stack.
2451 True and False are assumed to contain Symbols or Ident etc.
2452 *)
2453
2454 PROCEDURE PushTFntok (True, False, n: WORD; tokno: CARDINAL) ;
2455
2456
2457 (*
2458 PopTFn - Pop a True and False number from the True/False stack.
2459 True and False are assumed to contain Symbols or Ident etc.
2460 *)
2461
2462 PROCEDURE PopTFn (VAR True, False, n: WORD) ;
2463
2464
2465 (*
2466 PopNothing - pops the top element on the stack.
2467 *)
2468
2469 PROCEDURE PopNothing ;
2470
2471
2472 (*
2473 PopN - pops multiple elements from the BoolStack.
2474 *)
2475
2476 PROCEDURE PopN (n: CARDINAL) ;
2477
2478
2479 (*
2480 PushTFA - Push True, False, Array, numbers onto the
2481 True/False stack. True and False are assumed to
2482 contain Symbols or Ident etc.
2483 *)
2484
2485 PROCEDURE PushTFA (True, False, Array: WORD) ;
2486
2487
2488 (*
2489 OperandTok - returns the token associated with pos, on the stack.
2490 *)
2491
2492 PROCEDURE OperandTok (pos: CARDINAL) : WORD ;
2493
2494
2495 (*
2496 OperandA - returns possible array symbol associated with the ident
2497 operand stored on the boolean stack.
2498 *)
2499
2500 PROCEDURE OperandA (pos: CARDINAL) : WORD ;
2501
2502
2503 (*
2504 OperandAnno - returns the annotation string associated with the
2505 position, n, on the stack.
2506 *)
2507
2508 PROCEDURE OperandAnno (n: CARDINAL) : String ;
2509
2510
2511 (*
2512 Annotate - annotate the top of stack.
2513 *)
2514
2515 PROCEDURE Annotate (a: ARRAY OF CHAR) ;
2516
2517
2518 (*
2519 DisplayStack - displays the compile time symbol stack.
2520 *)
2521
2522 PROCEDURE DisplayStack ;
2523
2524
2525 (*
2526 Top - returns the no of items held in the stack.
2527 *)
2528
2529 PROCEDURE Top () : CARDINAL ;
2530
2531
2532 (*
2533 DupFrame - duplicate the top of stack and push the new frame.
2534 *)
2535
2536 PROCEDURE DupFrame ;
2537
2538
2539 (*
2540 WriteOperand - displays the operands name, symbol id and mode of addressing.
2541 *)
2542
2543 PROCEDURE WriteOperand (Sym: CARDINAL) ;
2544
2545
2546 (*
2547 BeginVarient - begin a varient record.
2548 *)
2549
2550 PROCEDURE BeginVarient ;
2551
2552
2553 (*
2554 EndVarient - end a varient record.
2555 *)
2556
2557 PROCEDURE EndVarient ;
2558
2559
2560 (*
2561 ElseVarient - associate an ELSE clause with a varient record.
2562 *)
2563
2564 PROCEDURE ElseVarient ;
2565
2566
2567 (*
2568 BeginVarientList - begin an ident list containing ranges belonging to a
2569 varient list.
2570 *)
2571
2572 PROCEDURE BeginVarientList ;
2573
2574
2575 (*
2576 EndVarientList - end a range list for a varient field.
2577 *)
2578
2579 PROCEDURE EndVarientList ;
2580
2581
2582 (*
2583 AddRecordToList - adds the record held on the top of stack to the
2584 list of records and varient fields.
2585 *)
2586
2587 PROCEDURE AddRecordToList ;
2588
2589
2590 (*
2591 AddVarientToList - adds varient held on the top of stack to the list.
2592 *)
2593
2594 PROCEDURE AddVarientToList ;
2595
2596
2597 (*
2598 AddVarientFieldToList - adds varient field, f, to the list of all varient
2599 fields created.
2600 *)
2601
2602 PROCEDURE AddVarientFieldToList (f: CARDINAL) ;
2603
2604
2605 (*
2606 AddVarientRange - creates a range from the top two contant expressions
2607 on the stack which are recorded with the current
2608 varient field. The stack is unaltered.
2609 *)
2610
2611 PROCEDURE AddVarientRange ;
2612
2613
2614 (*
2615 AddVarientEquality - adds the contant expression on the top of the stack
2616 to the current varient field being recorded.
2617 The stack is unaltered.
2618 *)
2619
2620 PROCEDURE AddVarientEquality ;
2621
2622
2623 (*
2624 BuildCodeOn - generates a quadruple declaring that code should be
2625 emitted from henceforth.
2626
2627 The Stack is unnaffected.
2628 *)
2629
2630 PROCEDURE BuildCodeOn ;
2631
2632
2633 (*
2634 BuildCodeOff - generates a quadruple declaring that code should not be
2635 emmitted from henceforth.
2636
2637 The Stack is unnaffected.
2638 *)
2639
2640 PROCEDURE BuildCodeOff ;
2641
2642
2643 (*
2644 BuildProfileOn - generates a quadruple declaring that profile timings
2645 should be emmitted from henceforth.
2646
2647 The Stack is unnaffected.
2648 *)
2649
2650 PROCEDURE BuildProfileOn ;
2651
2652
2653 (*
2654 BuildProfileOn - generates a quadruple declaring that profile timings
2655 should be emmitted from henceforth.
2656
2657 The Stack is unnaffected.
2658 *)
2659
2660 PROCEDURE BuildProfileOff ;
2661
2662
2663 (*
2664 BuildOptimizeOn - generates a quadruple declaring that optimization
2665 should occur from henceforth.
2666
2667 The Stack is unnaffected.
2668 *)
2669
2670 PROCEDURE BuildOptimizeOn ;
2671
2672
2673 (*
2674 BuildOptimizeOff - generates a quadruple declaring that optimization
2675 should not occur from henceforth.
2676
2677 The Stack is unnaffected.
2678 *)
2679
2680 PROCEDURE BuildOptimizeOff ;
2681
2682
2683 (*
2684 BuildAsm - builds an Inline pseudo quadruple operator.
2685 The inline interface, Sym, is stored as the operand
2686 to the operator InlineOp.
2687
2688 The stack is expected to contain:
2689
2690
2691 Entry Exit
2692 ===== ====
2693
2694 Ptr ->
2695 +--------------+
2696 | Sym | Empty
2697 |--------------|
2698 *)
2699
2700 PROCEDURE BuildAsm (tok: CARDINAL) ;
2701
2702
2703 (*
2704 BuildLineNo - builds a LineNumberOp pseudo quadruple operator.
2705 This quadruple indicates which source line has been
2706 processed, these quadruples are only generated if we
2707 are producing runtime debugging information.
2708
2709 The stack is not affected, read or altered in any way.
2710
2711
2712 Entry Exit
2713 ===== ====
2714
2715 Ptr -> <- Ptr
2716 *)
2717
2718 PROCEDURE BuildLineNo ;
2719
2720
2721 (*
2722 PushLineNo - pushes the current file and line number to the stack.
2723 *)
2724
2725 PROCEDURE PushLineNo ;
2726
2727
2728 (*
2729 BuildStmtNote - builds a StatementNoteOp pseudo quadruple operator.
2730 This quadruple indicates which source line has been
2731 processed and it represents the start of a statement
2732 sequence.
2733 It differs from LineNumberOp in that multiple successive
2734 LineNumberOps will be removed and the final one is attached to
2735 the next real GCC tree. Whereas a StatementNoteOp is always left
2736 alone. Depending upon the debugging level it will issue a nop
2737 instruction to ensure that the gdb single step will step into
2738 this line. Practically it allows pedalogical debugging to
2739 occur when there is syntax sugar such as:
2740
2741
2742 END (* step *)
2743 END (* step *)
2744 END ; (* step *)
2745 a := 1 ; (* step *)
2746
2747 REPEAT (* step *)
2748 i := 1 (* step *)
2749
2750 The stack is not affected, read or altered in any way.
2751
2752
2753 Entry Exit
2754 ===== ====
2755
2756 Ptr -> <- Ptr
2757 *)
2758
2759 PROCEDURE BuildStmtNote (offset: INTEGER) ;
2760
2761
2762 (*
2763 LoopAnalysis - checks whether an infinite loop exists.
2764 *)
2765
2766 PROCEDURE LoopAnalysis (Scope: CARDINAL; Current, End: CARDINAL) ;
2767
2768
2769 (*
2770 ForLoopAnalysis - checks all the FOR loops for index variable manipulation
2771 and dangerous usage outside the loop.
2772 *)
2773
2774 PROCEDURE ForLoopAnalysis ;
2775
2776
2777 (*
2778 BuildSizeCheckStart - switches off all quadruple generation if the function SIZE
2779 is being "called". This should be done as SIZE only requires the
2780 actual type of the expression, not its value. Consider the problem of
2781 SIZE(UninitializedPointer^) quite legal and it must also be safe!
2782
2783
2784 The Stack is expected to contain:
2785
2786
2787 Entry Exit
2788 ===== ====
2789
2790 Ptr -> <- Ptr
2791 +------------+ +-----------+
2792 | ProcSym | | ProcSym |
2793 |------------| |-----------|
2794 *)
2795
2796 PROCEDURE BuildSizeCheckStart ;
2797
2798
2799 (*
2800 BackPatchSubrangesAndOptParam - runs through all the quadruples and finds SubrangeLow or SubrangeHigh
2801 quadruples and replaces it by an assignment to the Low or High component
2802 of the subrange type.
2803
2804 Input:
2805 SubrangeLow op1 op3 (* op3 is a subrange *)
2806
2807 Output:
2808 Becomes op1 low
2809
2810 Input:
2811 SubrangeHigh op1 op3 (* op3 is a subrange *)
2812
2813 Output:
2814 Becomes op1 high
2815
2816 Input:
2817 OptParam op1 op2 op3
2818
2819 Output:
2820 Param op1 op2 GetOptArgInit(op3)
2821 *)
2822
2823 PROCEDURE BackPatchSubrangesAndOptParam ;
2824
2825
2826 (*
2827 WriteOperator - writes the name of the quadruple operator.
2828 *)
2829
2830 PROCEDURE WriteOperator (Operator: QuadOperator) ;
2831
2832
2833 (*
2834 PushAutoOn - push the auto flag and then set it to TRUE.
2835 Any call to ident in the parser will result in the token being pushed.
2836 *)
2837
2838 PROCEDURE PushAutoOn ;
2839
2840
2841 (*
2842 PushAutoOff - push the auto flag and then set it to FALSE.
2843 *)
2844
2845 PROCEDURE PushAutoOff ;
2846
2847
2848 (*
2849 IsAutoPushOn - returns the value of the current Auto ident push flag.
2850 *)
2851
2852 PROCEDURE IsAutoPushOn () : BOOLEAN ;
2853
2854
2855 (*
2856 PopAuto - restores the previous value of the Auto flag.
2857 *)
2858
2859 PROCEDURE PopAuto ;
2860
2861
2862 (*
2863 MustCheckOverflow - returns TRUE if the quadruple should test for overflow.
2864 *)
2865
2866 PROCEDURE MustCheckOverflow (q: CARDINAL) : BOOLEAN ;
2867
2868
2869 (*
2870 PushInConstExpression - push the InConstExpression flag and then set it to TRUE.
2871 *)
2872
2873 PROCEDURE PushInConstExpression ;
2874
2875
2876 (*
2877 PopInConstExpression - restores the previous value of the InConstExpression.
2878 *)
2879
2880 PROCEDURE PopInConstExpression ;
2881
2882
2883 (*
2884 IsInConstExpression - returns the value of the InConstExpression.
2885 *)
2886
2887 PROCEDURE IsInConstExpression () : BOOLEAN ;
2888
2889
2890 (*
2891 PushInConstParameters - push the InConstParameters flag and then set it to TRUE.
2892 *)
2893
2894 PROCEDURE PushInConstParameters ;
2895
2896
2897 (*
2898 PopInConstParameters - restores the previous value of the InConstParameters.
2899 *)
2900
2901 PROCEDURE PopInConstParameters ;
2902
2903
2904 (*
2905 IsInConstParameters - returns the value of the InConstParameters.
2906 *)
2907
2908 PROCEDURE IsInConstParameters () : BOOLEAN ;
2909
2910
2911 (*
2912 BuildAsmElement - the stack is expected to contain:
2913
2914
2915 Entry Exit
2916 ===== ====
2917
2918 Ptr ->
2919 +------------------+
2920 | expr | tokpos |
2921 |------------------|
2922 | str |
2923 |------------------|
2924 | name |
2925 |------------------| +------------------+
2926 | CurrentInterface | | CurrentInterface |
2927 |------------------| |------------------|
2928 | CurrentAsm | | CurrentAsm |
2929 |------------------| |------------------|
2930 | n | | n |
2931 |------------------| |------------------|
2932 *)
2933
2934 PROCEDURE BuildAsmElement (input, output: BOOLEAN) ;
2935
2936
2937 (*
2938 BuildAsmTrash - the stack is expected to contain:
2939
2940
2941 Entry Exit
2942 ===== ====
2943
2944 Ptr ->
2945 +------------------+
2946 | expr | tokpos |
2947 |------------------| +------------------+
2948 | CurrentInterface | | CurrentInterface |
2949 |------------------| |------------------|
2950 | CurrentAsm | | CurrentAsm |
2951 |------------------| |------------------|
2952 | n | | n |
2953 |------------------| |------------------|
2954 *)
2955
2956 PROCEDURE BuildAsmTrash ;
2957
2958
2959 (*
2960 GetQuadTrash - return the symbol associated with the trashed operand.
2961 *)
2962
2963 PROCEDURE GetQuadTrash (quad: CARDINAL) : CARDINAL ;
2964
2965
2966 END M2Quads.