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