]>
Commit | Line | Data |
---|---|---|
1eee94d3 GM |
1 | (* M2ALU.def gcc implementation of the M2ALU module. |
2 | ||
83ffe9cd | 3 | Copyright (C) 2001-2023 Free Software Foundation, Inc. |
1eee94d3 GM |
4 | Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. |
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 M2ALU ; | |
23 | ||
24 | (* | |
25 | Title : M2ALU.def | |
26 | Author : Gaius Mulley | |
27 | System : UNIX (gm2) | |
28 | Date : Tue Jul 11 09:14:28 2000 | |
29 | Description: Handles all values in the Modula-2 compiler and all | |
30 | manipulations of values. All values are mapped onto | |
31 | gcc trees. | |
32 | *) | |
33 | ||
34 | FROM NameKey IMPORT Name ; | |
35 | FROM m2tree IMPORT Tree ; | |
36 | FROM M2GCCDeclare IMPORT WalkAction, IsAction ; | |
37 | ||
38 | EXPORT QUALIFIED PtrToValue, | |
39 | InitValue, | |
40 | IsValueTypeNone, | |
41 | IsValueTypeInteger, | |
42 | IsValueTypeReal, | |
43 | IsValueTypeComplex, | |
44 | IsValueTypeSet, | |
45 | IsValueTypeConstructor, | |
46 | IsValueTypeArray, | |
47 | IsValueTypeRecord, | |
48 | PopInto, PushFrom, | |
49 | PushIntegerTree, PopIntegerTree, | |
50 | PushSetTree, PopSetTree, | |
51 | PushRealTree, PopRealTree, | |
52 | PushComplexTree, PopComplexTree, | |
53 | PopConstructorTree, | |
54 | PushCard, | |
55 | PushInt, | |
56 | PushChar, | |
57 | PushString, | |
58 | PushTypeOfTree, | |
59 | CoerseLongRealToCard, | |
60 | ConvertRealToInt, | |
61 | ConvertToInt, | |
62 | ConvertToType, | |
63 | GetSetValueType, | |
64 | IsSolved, IsValueConst, | |
65 | PutConstructorSolved, EvaluateValue, TryEvaluateValue, | |
66 | ||
67 | IsNulSet, IsGenericNulSet, PushNulSet, AddBitRange, AddBit, SubBit, | |
68 | SetOr, SetAnd, SetIn, | |
69 | SetDifference, SetSymmetricDifference, | |
70 | SetNegate, SetShift, SetRotate, | |
71 | ||
72 | Addn, Multn, Sub, | |
73 | DivFloor, ModFloor, DivTrunc, ModTrunc, | |
74 | Equ, NotEqu, Less, Gre, LessEqu, GreEqu, | |
75 | GetValue, GetRange, ConstructSetConstant, BuildRange, | |
76 | IsConstructorDependants, WalkConstructorDependants, | |
77 | AddField, AddElements, | |
78 | ||
79 | PushEmptyConstructor, PushEmptyArray, PushEmptyRecord, | |
80 | ChangeToConstructor, | |
81 | ||
82 | IsValueAndTreeKnown, CheckOrResetOverflow ; | |
83 | ||
84 | TYPE | |
85 | PtrToValue ; | |
86 | ||
87 | ||
88 | (* | |
89 | InitValue - initializes and returns a value container. | |
90 | *) | |
91 | ||
92 | PROCEDURE InitValue () : PtrToValue ; | |
93 | ||
94 | ||
95 | (* | |
96 | IsValueTypeNone - returns TRUE if the value on the top stack has no value. | |
97 | *) | |
98 | ||
99 | PROCEDURE IsValueTypeNone () : BOOLEAN ; | |
100 | ||
101 | ||
102 | (* | |
103 | IsValueTypeInteger - returns TRUE if the value on the top stack is an integer. | |
104 | *) | |
105 | ||
106 | PROCEDURE IsValueTypeInteger () : BOOLEAN ; | |
107 | ||
108 | ||
109 | (* | |
110 | IsValueTypeReal - returns TRUE if the value on the top stack is a real. | |
111 | *) | |
112 | ||
113 | PROCEDURE IsValueTypeReal () : BOOLEAN ; | |
114 | ||
115 | ||
116 | (* | |
117 | IsValueTypeComplex - returns TRUE if the value on the top stack is a complex. | |
118 | *) | |
119 | ||
120 | PROCEDURE IsValueTypeComplex () : BOOLEAN ; | |
121 | ||
122 | ||
123 | (* | |
124 | IsValueTypeSet - returns TRUE if the value on the top stack is a set. | |
125 | *) | |
126 | ||
127 | PROCEDURE IsValueTypeSet () : BOOLEAN ; | |
128 | ||
129 | ||
130 | (* | |
131 | IsValueTypeConstructor - returns TRUE if the value on the top | |
132 | stack is a constructor. | |
133 | *) | |
134 | ||
135 | PROCEDURE IsValueTypeConstructor () : BOOLEAN ; | |
136 | ||
137 | ||
138 | (* | |
139 | IsValueTypeArray - returns TRUE if the value on the top | |
140 | stack is an array. | |
141 | *) | |
142 | ||
143 | PROCEDURE IsValueTypeArray () : BOOLEAN ; | |
144 | ||
145 | ||
146 | (* | |
147 | IsValueTypeRecord - returns TRUE if the value on the top | |
148 | stack is a record. | |
149 | *) | |
150 | ||
151 | PROCEDURE IsValueTypeRecord () : BOOLEAN ; | |
152 | ||
153 | ||
154 | (* | |
155 | GetSetValueType - returns the set type on top of the ALU stack. | |
156 | *) | |
157 | ||
158 | PROCEDURE GetSetValueType () : CARDINAL ; | |
159 | ||
160 | ||
161 | (* | |
162 | PushIntegerTree - pushes a gcc tree value onto the ALU stack. | |
163 | *) | |
164 | ||
165 | PROCEDURE PushIntegerTree (t: Tree) ; | |
166 | ||
167 | ||
168 | (* | |
169 | PopIntegerTree - pops a gcc tree value from the ALU stack. | |
170 | *) | |
171 | ||
172 | PROCEDURE PopIntegerTree () : Tree ; | |
173 | ||
174 | ||
175 | (* | |
176 | PushRealTree - pushes a gcc tree value onto the ALU stack. | |
177 | *) | |
178 | ||
179 | PROCEDURE PushRealTree (t: Tree) ; | |
180 | ||
181 | ||
182 | (* | |
183 | PopRealTree - pops a gcc tree value from the ALU stack. | |
184 | *) | |
185 | ||
186 | PROCEDURE PopRealTree () : Tree ; | |
187 | ||
188 | ||
189 | (* | |
190 | PushComplexTree - pushes a gcc tree value onto the ALU stack. | |
191 | *) | |
192 | ||
193 | PROCEDURE PushComplexTree (t: Tree) ; | |
194 | ||
195 | ||
196 | (* | |
197 | PopComplexTree - pops a gcc tree value from the ALU stack. | |
198 | *) | |
199 | ||
200 | PROCEDURE PopComplexTree () : Tree ; | |
201 | ||
202 | ||
203 | (* | |
204 | PushSetTree - pushes a gcc tree onto the ALU stack. | |
205 | The tree, t, is expected to contain a | |
206 | word value. It is converted into a set | |
207 | type (sym). Bit 0 maps onto MIN(sym). | |
208 | *) | |
209 | ||
210 | PROCEDURE PushSetTree (tokenno: CARDINAL; | |
211 | t: Tree; sym: CARDINAL) ; | |
212 | ||
213 | ||
214 | (* | |
215 | PopSetTree - pops a gcc tree from the ALU stack. | |
216 | *) | |
217 | ||
218 | PROCEDURE PopSetTree (tokenno: CARDINAL) : Tree ; | |
219 | ||
220 | ||
221 | (* | |
222 | PopConstructorTree - returns a tree containing the compound literal. | |
223 | *) | |
224 | ||
225 | PROCEDURE PopConstructorTree (tokenno: CARDINAL) : Tree ; | |
226 | ||
227 | ||
228 | (* | |
229 | PushFrom - pushes a copy of the contents of, v, onto stack. | |
230 | *) | |
231 | ||
232 | PROCEDURE PushFrom (v: PtrToValue) ; | |
233 | ||
234 | ||
235 | (* | |
236 | PopInto - pops the top element from the stack and places it into, v. | |
237 | *) | |
238 | ||
239 | PROCEDURE PopInto (v: PtrToValue) ; | |
240 | ||
241 | ||
242 | (* | |
243 | PushCard - pushes a cardinal onto the stack. | |
244 | *) | |
245 | ||
246 | PROCEDURE PushCard (c: CARDINAL) ; | |
247 | ||
248 | ||
249 | (* | |
250 | PushInt - pushes an integer onto the stack. | |
251 | *) | |
252 | ||
253 | PROCEDURE PushInt (i: INTEGER) ; | |
254 | ||
255 | ||
256 | (* | |
257 | PushChar - pushes a char onto the stack. | |
258 | *) | |
259 | ||
260 | PROCEDURE PushChar (c: CHAR) ; | |
261 | ||
262 | ||
263 | (* | |
264 | PushString - pushes the numerical value of the string onto the stack. | |
265 | *) | |
266 | ||
267 | PROCEDURE PushString (tokenno: CARDINAL; s: Name) ; | |
268 | ||
269 | ||
270 | (* | |
271 | CoerseLongRealToCard - performs a coersion between a REAL to a CARDINAL | |
272 | *) | |
273 | ||
274 | PROCEDURE CoerseLongRealToCard ; | |
275 | ||
276 | ||
277 | (* | |
278 | ConvertRealToInt - converts a REAL into an INTEGER | |
279 | *) | |
280 | ||
281 | PROCEDURE ConvertRealToInt ; | |
282 | ||
283 | ||
284 | (* | |
285 | ConvertToInt - converts the value into an INTEGER. This should be used | |
286 | if we are computing the number of elements in a char set to | |
287 | avoid an overflow. | |
288 | *) | |
289 | ||
290 | PROCEDURE ConvertToInt ; | |
291 | ||
292 | ||
293 | (* | |
294 | ConvertToType - converts the top of stack to type, t. | |
295 | *) | |
296 | ||
297 | PROCEDURE ConvertToType (t: CARDINAL) ; | |
298 | ||
299 | ||
300 | (* | |
301 | IsSolved - returns true if the memory cell indicated by v | |
302 | has a known value. | |
303 | *) | |
304 | ||
305 | PROCEDURE IsSolved (v: PtrToValue) : BOOLEAN ; | |
306 | ||
307 | ||
308 | (* | |
309 | PutConstructorSolved - records that this constructor is solved. | |
310 | *) | |
311 | ||
312 | PROCEDURE PutConstructorSolved (sym: CARDINAL) ; | |
313 | ||
314 | ||
315 | (* | |
316 | EvaluateValue - attempts to evaluate the symbol, sym, value. | |
317 | *) | |
318 | ||
319 | PROCEDURE EvaluateValue (sym: CARDINAL) ; | |
320 | ||
321 | ||
322 | (* | |
323 | TryEvaluateValue - attempts to evaluate the symbol, sym, value. | |
324 | *) | |
325 | ||
326 | PROCEDURE TryEvaluateValue (sym: CARDINAL) ; | |
327 | ||
328 | ||
329 | (* | |
330 | Add - adds the top two elements on the stack. | |
331 | ||
332 | The Stack: | |
333 | ||
334 | Entry Exit | |
335 | ||
336 | Ptr -> | |
337 | +------------+ | |
338 | | Op1 | <- Ptr | |
339 | |------------| +------------+ | |
340 | | Op2 | | Op2 + Op1 | | |
341 | |------------| |------------| | |
342 | *) | |
343 | ||
344 | PROCEDURE Addn ; | |
345 | ||
346 | ||
347 | (* | |
348 | Sub - subtracts the top two elements on the stack. | |
349 | ||
350 | The Stack: | |
351 | ||
352 | Entry Exit | |
353 | ||
354 | Ptr -> | |
355 | +------------+ | |
356 | | Op1 | <- Ptr | |
357 | |------------| +------------+ | |
358 | | Op2 | | Op2 - Op1 | | |
359 | |------------| |------------| | |
360 | *) | |
361 | ||
362 | PROCEDURE Sub ; | |
363 | ||
364 | ||
365 | (* | |
366 | Mult - multiplies the top two elements on the stack. | |
367 | ||
368 | The Stack: | |
369 | ||
370 | Entry Exit | |
371 | ||
372 | Ptr -> | |
373 | +------------+ | |
374 | | Op1 | <- Ptr | |
375 | |------------| +------------+ | |
376 | | Op2 | | Op2 * Op1 | | |
377 | |------------| |------------| | |
378 | *) | |
379 | ||
380 | PROCEDURE Multn ; | |
381 | ||
382 | ||
383 | (* | |
384 | DivFloor - divides the top two elements on the stack. | |
385 | ||
386 | The Stack: | |
387 | ||
388 | Entry Exit | |
389 | ||
390 | Ptr -> | |
391 | +------------+ | |
392 | | Op1 | <- Ptr | |
393 | |------------| +--------------+ | |
394 | | Op2 | | Op2 DIV Op1 | | |
395 | |------------| |--------------| | |
396 | *) | |
397 | ||
398 | PROCEDURE DivFloor ; | |
399 | ||
400 | ||
401 | (* | |
402 | ModFloor - modulus of the top two elements on the stack. | |
403 | ||
404 | The Stack: | |
405 | ||
406 | Entry Exit | |
407 | ||
408 | Ptr -> | |
409 | +------------+ | |
410 | | Op1 | <- Ptr | |
411 | |------------| +--------------+ | |
412 | | Op2 | | Op2 MOD Op1 | | |
413 | |------------| |--------------| | |
414 | *) | |
415 | ||
416 | PROCEDURE ModFloor ; | |
417 | ||
418 | ||
419 | (* | |
420 | DivTrunc - divides the top two elements on the stack. | |
421 | ||
422 | The Stack: | |
423 | ||
424 | Entry Exit | |
425 | ||
426 | Ptr -> | |
427 | +------------+ | |
428 | | Op1 | <- Ptr | |
429 | |------------| +--------------+ | |
430 | | Op2 | | Op2 DIV Op1 | | |
431 | |------------| |--------------| | |
432 | *) | |
433 | ||
434 | PROCEDURE DivTrunc ; | |
435 | ||
436 | ||
437 | (* | |
438 | ModTrunc - modulus of the top two elements on the stack. | |
439 | ||
440 | The Stack: | |
441 | ||
442 | Entry Exit | |
443 | ||
444 | Ptr -> | |
445 | +------------+ | |
446 | | Op1 | <- Ptr | |
447 | |------------| +--------------+ | |
448 | | Op2 | | Op2 MOD Op1 | | |
449 | |------------| |--------------| | |
450 | *) | |
451 | ||
452 | PROCEDURE ModTrunc ; | |
453 | ||
454 | ||
455 | (* | |
456 | Equ - returns true if the top two elements on the stack | |
457 | are identical. | |
458 | ||
459 | The Stack: | |
460 | ||
461 | Entry Exit | |
462 | ||
463 | Ptr -> | |
464 | +------------+ | |
465 | | Op1 | | |
466 | |------------| | |
467 | | Op2 | | |
468 | |------------| Empty | |
469 | ||
470 | RETURN( Op2 = Op1 ) | |
471 | *) | |
472 | ||
473 | PROCEDURE Equ (tokenno: CARDINAL) : BOOLEAN ; | |
474 | ||
475 | ||
476 | (* | |
477 | NotEqu - returns true if the top two elements on the stack | |
478 | are not identical. | |
479 | ||
480 | The Stack: | |
481 | ||
482 | Entry Exit | |
483 | ||
484 | Ptr -> | |
485 | +------------+ | |
486 | | Op1 | | |
487 | |------------| | |
488 | | Op2 | | |
489 | |------------| Empty | |
490 | ||
491 | RETURN( Op2 # Op1 ) | |
492 | *) | |
493 | ||
494 | PROCEDURE NotEqu (tokenno: CARDINAL) : BOOLEAN ; | |
495 | ||
496 | ||
497 | (* | |
498 | Less - returns true if Op2 < Op1. | |
499 | ||
500 | The Stack: | |
501 | ||
502 | Entry Exit | |
503 | ||
504 | Ptr -> | |
505 | +------------+ | |
506 | | Op1 | | |
507 | |------------| | |
508 | | Op2 | | |
509 | |------------| Empty | |
510 | ||
511 | RETURN( Op2 < Op1 ) | |
512 | *) | |
513 | ||
514 | PROCEDURE Less (tokenno: CARDINAL) : BOOLEAN ; | |
515 | ||
516 | ||
517 | (* | |
518 | Gre - returns true if Op2 > Op1 | |
519 | ||
520 | The Stack: | |
521 | ||
522 | Entry Exit | |
523 | ||
524 | Ptr -> | |
525 | +------------+ | |
526 | | Op1 | | |
527 | |------------| | |
528 | | Op2 | | |
529 | |------------| Empty | |
530 | ||
531 | RETURN( Op2 > Op1 ) | |
532 | *) | |
533 | ||
534 | PROCEDURE Gre (tokenno: CARDINAL) : BOOLEAN ; | |
535 | ||
536 | ||
537 | (* | |
538 | LessEqu - returns true if Op2 <= Op1 | |
539 | ||
540 | The Stack: | |
541 | ||
542 | Entry Exit | |
543 | ||
544 | Ptr -> | |
545 | +------------+ | |
546 | | Op1 | | |
547 | |------------| | |
548 | | Op2 | | |
549 | |------------| Empty | |
550 | ||
551 | RETURN( Op2 <= Op1 ) | |
552 | *) | |
553 | ||
554 | PROCEDURE LessEqu (tokenno: CARDINAL) : BOOLEAN ; | |
555 | ||
556 | ||
557 | (* | |
558 | GreEqu - returns true if Op2 >= Op1 | |
559 | are not identical. | |
560 | ||
561 | The Stack: | |
562 | ||
563 | Entry Exit | |
564 | ||
565 | Ptr -> | |
566 | +------------+ | |
567 | | Op1 | | |
568 | |------------| | |
569 | | Op2 | | |
570 | |------------| Empty | |
571 | ||
572 | RETURN( Op2 >= Op1 ) | |
573 | *) | |
574 | ||
575 | PROCEDURE GreEqu (tokenno: CARDINAL) : BOOLEAN ; | |
576 | ||
577 | ||
578 | (* | |
579 | IsNulSet - returns TRUE if the top element is the nul set constant, {}. | |
580 | *) | |
581 | ||
582 | PROCEDURE IsNulSet () : BOOLEAN ; | |
583 | ||
584 | ||
585 | (* | |
586 | IsGenericNulSet - returns TRUE if the top element is the generic nul set constant, {}. | |
587 | *) | |
588 | ||
589 | PROCEDURE IsGenericNulSet () : BOOLEAN ; | |
590 | ||
591 | ||
592 | (* | |
593 | PushNulSet - pushes an empty set {} onto the ALU stack. The subrange type used | |
594 | to construct the set is defined by, type. If this is NulSym then | |
595 | the set is generic and compatible with all sets. | |
596 | ||
597 | The Stack: | |
598 | ||
599 | Entry Exit | |
600 | ||
601 | <- Ptr | |
602 | +------------+ | |
603 | | {} | | |
604 | Ptr -> |------------| | |
605 | ||
606 | *) | |
607 | ||
608 | PROCEDURE PushNulSet (settype: CARDINAL) ; | |
609 | ||
610 | ||
611 | (* | |
612 | AddBitRange - adds the range op1..op2 to the underlying set. | |
613 | ||
614 | Ptr -> | |
615 | <- Ptr | |
616 | +------------+ +------------+ | |
617 | | Set | | Set | | |
618 | |------------| |------------| | |
619 | *) | |
620 | ||
621 | PROCEDURE AddBitRange (tokenno: CARDINAL; op1, op2: CARDINAL) ; | |
622 | ||
623 | ||
624 | (* | |
625 | AddBit - adds the bit op1 to the underlying set. INCL(Set, op1) | |
626 | ||
627 | Ptr -> | |
628 | <- Ptr | |
629 | +------------+ +------------+ | |
630 | | Set | | Set | | |
631 | |------------| |------------| | |
632 | *) | |
633 | ||
634 | PROCEDURE AddBit (tokenno: CARDINAL; op1: CARDINAL) ; | |
635 | ||
636 | ||
637 | (* | |
638 | SubBit - removes a bit op1 from the underlying set. EXCL(Set, Op1) | |
639 | ||
640 | Ptr -> | |
641 | +------------+ | |
642 | | Op1 | <- Ptr | |
643 | |------------| +------------+ | |
644 | | Set | | Set | | |
645 | |------------| |------------| | |
646 | *) | |
647 | ||
648 | PROCEDURE SubBit (tokenno: CARDINAL; op1: CARDINAL) ; | |
649 | ||
650 | ||
651 | (* | |
652 | SetIn - returns true if the Op1 IN Set | |
653 | ||
654 | The Stack: | |
655 | ||
656 | Entry Exit | |
657 | ||
658 | Ptr -> | |
659 | +------------+ | |
660 | | Set | | |
661 | |------------| | |
662 | | Op1 | | |
663 | |------------| Empty | |
664 | ||
665 | RETURN( Op1 IN Set ) | |
666 | *) | |
667 | ||
668 | PROCEDURE SetIn (tokenno: CARDINAL; Op1: CARDINAL) : BOOLEAN ; | |
669 | ||
670 | ||
671 | (* | |
672 | SetOr - performs an inclusive OR of the top two sets on the stack. | |
673 | ||
674 | The Stack: | |
675 | ||
676 | Entry Exit | |
677 | ||
678 | Ptr -> | |
679 | +------------+ | |
680 | | Op1 | <- Ptr | |
681 | |------------| +------------+ | |
682 | | Op2 | | Op2 + Op1 | | |
683 | |------------| |------------| | |
684 | ||
685 | *) | |
686 | ||
687 | PROCEDURE SetOr (tokenno: CARDINAL) ; | |
688 | ||
689 | ||
690 | (* | |
691 | SetAnd - performs a set AND the top two sets on the stack. | |
692 | ||
693 | The Stack: | |
694 | ||
695 | Entry Exit | |
696 | ||
697 | Ptr -> | |
698 | +------------+ | |
699 | | Op1 | <- Ptr | |
700 | |------------| +------------+ | |
701 | | Op2 | | Op2 * Op1 | | |
702 | |------------| |------------| | |
703 | *) | |
704 | ||
705 | PROCEDURE SetAnd (tokenno: CARDINAL) ; | |
706 | ||
707 | ||
708 | (* | |
709 | SetDifference - performs a set difference of the top two elements on the stack. | |
710 | For each member in the set | |
711 | if member in Op2 and not member in Op1 | |
712 | ||
713 | The Stack: | |
714 | ||
715 | Entry Exit | |
716 | ||
717 | Ptr -> | |
718 | +------------+ | |
719 | | Op1 | <- Ptr | |
720 | |------------| +-------------------+ | |
721 | | Op2 | | Op2 and (not Op1) | | |
722 | |------------| |-------------------| | |
723 | *) | |
724 | ||
725 | PROCEDURE SetDifference (tokenno: CARDINAL) ; | |
726 | ||
727 | ||
728 | (* | |
729 | SetSymmetricDifference - performs a set difference of the top two sets on the stack. | |
730 | ||
731 | The Stack: | |
732 | ||
733 | Entry Exit | |
734 | ||
735 | Ptr -> | |
736 | +------------+ | |
737 | | Op1 | <- Ptr | |
738 | |------------| +------------+ | |
739 | | Op2 | | Op2 - Op1 | | |
740 | |------------| |------------| | |
741 | *) | |
742 | ||
743 | PROCEDURE SetSymmetricDifference (tokenno: CARDINAL) ; | |
744 | ||
745 | ||
746 | (* | |
747 | SetNegate - negates the top set on the stack. | |
748 | ||
749 | Ptr -> <- Ptr | |
750 | +-----------+ +------------+ | |
751 | | Set | | Set | | |
752 | |-----------| |------------| | |
753 | *) | |
754 | ||
755 | PROCEDURE SetNegate (tokenno: CARDINAL) ; | |
756 | ||
757 | ||
758 | (* | |
759 | SetShift - if op1 is positive | |
760 | then | |
761 | result := op2 << op1 | |
762 | else | |
763 | result := op2 >> op1 | |
764 | fi | |
765 | ||
766 | ||
767 | The Stack: | |
768 | ||
769 | Entry Exit | |
770 | ||
771 | Ptr -> | |
772 | +------------+ | |
773 | | Op1 | <- Ptr | |
774 | |------------| +------------+ | |
775 | | Op2 | | result | | |
776 | |------------| |------------| | |
777 | ||
778 | *) | |
779 | ||
780 | PROCEDURE SetShift (tokenno: CARDINAL) ; | |
781 | ||
782 | ||
783 | (* | |
784 | SetRotate - if op1 is positive | |
785 | then | |
786 | result := ROTATERIGHT(op2, op1) | |
787 | else | |
788 | result := ROTATELEFT(op2, op1) | |
789 | fi | |
790 | ||
791 | ||
792 | The Stack: | |
793 | ||
794 | Entry Exit | |
795 | ||
796 | Ptr -> | |
797 | +------------+ | |
798 | | Op1 | <- Ptr | |
799 | |------------| +------------+ | |
800 | | Op2 | | result | | |
801 | |------------| |------------| | |
802 | *) | |
803 | ||
804 | PROCEDURE SetRotate (tokenno: CARDINAL) ; | |
805 | ||
806 | ||
807 | (* | |
808 | GetValue - returns and pops the value from the top of stack. | |
809 | *) | |
810 | ||
811 | PROCEDURE GetValue (tokenno: CARDINAL) : PtrToValue ; | |
812 | ||
813 | ||
814 | (* | |
815 | GetRange - returns TRUE if range number, n, exists in the value, v. | |
816 | A non empty set is defined by having 1..N ranges | |
817 | *) | |
818 | ||
819 | PROCEDURE GetRange (v: PtrToValue; n: CARDINAL; VAR low, high: CARDINAL) : BOOLEAN ; | |
820 | ||
821 | ||
822 | (* | |
823 | ConstructSetConstant - builds a struct of integers which represents the | |
824 | set const, sym. | |
825 | *) | |
826 | ||
827 | PROCEDURE ConstructSetConstant (tokenno: CARDINAL; v: PtrToValue) : Tree ; | |
828 | ||
829 | ||
830 | (* | |
831 | BuildRange - returns a integer sized constant which represents the | |
832 | value {e1..e2}. | |
833 | *) | |
834 | ||
835 | PROCEDURE BuildRange (tokenno: CARDINAL; e1, e2: Tree) : Tree ; | |
836 | ||
837 | ||
838 | (* | |
839 | IsConstructorDependants - return TRUE if returned if all | |
840 | q(dependants) of, sym, return TRUE. | |
841 | *) | |
842 | ||
843 | PROCEDURE IsConstructorDependants (sym: CARDINAL; q: IsAction) : BOOLEAN ; | |
844 | ||
845 | ||
846 | (* | |
847 | WalkConstructorDependants - walk the constructor, sym, calling | |
848 | p for each dependant. | |
849 | *) | |
850 | ||
851 | PROCEDURE WalkConstructorDependants (sym: CARDINAL; p: WalkAction) ; | |
852 | ||
853 | ||
854 | (* | |
855 | IsValueAndTreeKnown - returns TRUE if the value is known and the gcc tree | |
856 | is defined. | |
857 | ||
858 | The Stack: | |
859 | ||
860 | Entry Exit | |
861 | ||
862 | Ptr -> | |
863 | +------------+ | |
864 | | Op1 | <- Ptr | |
865 | |------------| +------------+ | |
866 | *) | |
867 | ||
868 | PROCEDURE IsValueAndTreeKnown () : BOOLEAN ; | |
869 | ||
870 | ||
871 | (* | |
872 | CheckOrResetOverflow - tests to see whether the tree, t, has caused | |
873 | an overflow error and if so it generates an | |
874 | error message. | |
875 | *) | |
876 | ||
877 | PROCEDURE CheckOrResetOverflow (tokenno: CARDINAL; t: Tree; check: BOOLEAN) ; | |
878 | ||
879 | ||
880 | (* | |
881 | AddElements - adds the elements, el BY, n, to the array constant. | |
882 | ||
883 | Ptr -> | |
884 | <- Ptr | |
885 | +------------+ +------------+ | |
886 | | Array | | Array | | |
887 | |------------| |------------| | |
888 | ||
889 | *) | |
890 | ||
891 | PROCEDURE AddElements (tokenno: CARDINAL; el, n: CARDINAL) ; | |
892 | ||
893 | ||
894 | (* | |
895 | AddField - adds the field op1 to the underlying constructor. | |
896 | ||
897 | Ptr -> | |
898 | <- Ptr | |
899 | +------------+ +------------+ | |
900 | | const | | const | | |
901 | |------------| |------------| | |
902 | ||
903 | *) | |
904 | ||
905 | PROCEDURE AddField (tokenno: CARDINAL; op1: CARDINAL) ; | |
906 | ||
907 | ||
908 | (* | |
909 | PushEmptyConstructor - pushes an empty constructor {} onto the ALU stack. | |
910 | This is expected to be filled in by subsequent | |
911 | calls to AddElements, AddRange or AddField. | |
912 | ||
913 | The Stack: | |
914 | ||
915 | Entry Exit | |
916 | ||
917 | <- Ptr | |
918 | +------------+ | |
919 | | {} | | |
920 | Ptr -> |------------| | |
921 | ||
922 | *) | |
923 | ||
924 | PROCEDURE PushEmptyConstructor (constype: CARDINAL) ; | |
925 | ||
926 | ||
927 | (* | |
928 | PushEmptyArray - pushes an empty array {} onto the ALU stack. | |
929 | This is expected to be filled in by subsequent | |
930 | calls to AddElements. | |
931 | ||
932 | The Stack: | |
933 | ||
934 | Entry Exit | |
935 | ||
936 | <- Ptr | |
937 | +------------+ | |
938 | | {} | | |
939 | Ptr -> |------------| | |
940 | ||
941 | *) | |
942 | ||
943 | PROCEDURE PushEmptyArray (arraytype: CARDINAL) ; | |
944 | ||
945 | ||
946 | (* | |
947 | PushEmptyRecord - pushes an empty record {} onto the ALU stack. | |
948 | This is expected to be filled in by subsequent | |
949 | calls to AddField. | |
950 | ||
951 | The Stack: | |
952 | ||
953 | Entry Exit | |
954 | ||
955 | <- Ptr | |
956 | +------------+ | |
957 | | {} | | |
958 | Ptr -> |------------| | |
959 | ||
960 | *) | |
961 | ||
962 | PROCEDURE PushEmptyRecord (recordtype: CARDINAL) ; | |
963 | ||
964 | ||
965 | (* | |
966 | ChangeToConstructor - change the top of stack value to a constructor, type. | |
967 | *) | |
968 | ||
969 | PROCEDURE ChangeToConstructor (tokenno: CARDINAL; constype: CARDINAL) ; | |
970 | ||
971 | ||
972 | (* | |
973 | IsValueConst - returns true if the memory cell indicated by v | |
974 | is only defined by constants. For example | |
975 | no variables are used in the constructor. | |
976 | *) | |
977 | ||
978 | PROCEDURE IsValueConst (v: PtrToValue) : BOOLEAN ; | |
979 | ||
980 | ||
981 | (* | |
982 | PushTypeOfTree - pushes tree, gcc, to the stack and records the | |
983 | front end type. | |
984 | *) | |
985 | ||
986 | PROCEDURE PushTypeOfTree (sym: CARDINAL; gcc: Tree) ; | |
987 | ||
988 | ||
989 | END M2ALU. |