Преглед на файлове

fix(compiler): normalize leftover curDesc[N]/g6 in EXPRESS.MOD

Eric Streit преди 1 седмица
родител
ревизия
7dbd51634b
променени са 1 файла, в които са добавени 52 реда и са изтрити 52 реда
  1. 52 52
      src/compiler/EXPRESS.MOD

+ 52 - 52
src/compiler/EXPRESS.MOD

@@ -465,7 +465,7 @@ END ParseSelector;
 PROCEDURE ParseDesignatorTail;
 VAR buf: Desc; more: BOOLEAN;
 BEGIN
-  buf := curDesc; g6 := 0; EvalConstExpr; (*{0512-0517}*)
+  buf := curDesc; constMode := 0; EvalConstExpr; (*{0512-0517}*)
   LOOP
     IF (Scanner.curSymbol # 3) & ((Scanner.curSymbol-44) > 5) THEN EXIT END; (*{0519-0525}*)
     IF Scanner.AcceptSymbol(44) THEN (*{0528-052b} '(' actuals/indexqual *)
@@ -478,15 +478,15 @@ BEGIN
           END;
         END;
         buf := curDesc; ParseExpression; (*{054c-0550}*)
-        IF curDesc[2] = 0 THEN (*{0554-0556} typeless actual *)
+        IF curDesc.raw[2] = 0 THEN (*{0554-0556} typeless actual *)
           ConstToInt(Compiler.CardType, 44); PopExprDesc; (*{0559-055e}*)
           IF 8 IN Scanner.scanOptions THEN (*{0561}*)
             EmitAddress; CodeGen.QueueConst(0); CodeGen.EmitStandardOp(0); (*{0567-056d}*)
           END;
-          curDesc[3] := curDesc[3]-2; (*{0570-0575}*)
+          curDesc.raw[3] := curDesc.raw[3]-2; (*{0570-0575}*)
         ELSE (*{0578} typed actual *)
-          ConstToInt(curDesc[2], 44); ConstToCard(curDesc[2], curDesc[2]); (*{0579-057f}*)
-          CodeGen.QueueConst(curDesc[5]); CodeGen.EmitTypedOp(7, 0); (*{0580-0587}*)
+          ConstToInt(curDesc.raw[2], 44); ConstToCard(curDesc.raw[2], curDesc.raw[2]); (*{0579-057f}*)
+          CodeGen.QueueConst(curDesc.raw[5]); CodeGen.EmitTypedOp(7, 0); (*{0580-0587}*)
         END;
         IF more THEN CodeGen.EmitTypedOp(6, 0) END; (*{0589-058e}*)
         curDesc := buf; (*{0590-0592}*)
@@ -497,41 +497,41 @@ BEGIN
         END;
         more := TRUE; (*{05ad-05ae}*)
       END;
-      curDesc[4] := 5; g6 := 1; (*{05b1-055b} handler exit *)
+      curDesc.raw[4] := 5; constMode := 1; (*{05b1-055b} handler exit *)
     ELSIF Scanner.AcceptSymbol(46) THEN (*{05b8-05bb} '[' subscript *)
       PushOperand; (*{05be}*)
       IF (Compiler.rangeCheckEnabled # 0) & (8 IN Scanner.scanOptions) THEN (*{05c0-05c8}*)
         CodeGen.EmitStandardOp(6); (*{05ca-05c4}*)
       END;
-      IF curDesc[0] = Compiler.AddressType THEN curDesc[0] := Compiler.WordType ELSE (*{05cd-05d9}*)
+      IF curDesc.raw[0] = Compiler.AddressType THEN curDesc.raw[0] := Compiler.WordType ELSE (*{05cd-05d9}*)
         IF ~ MatchOpClass(32, 46) THEN (*{05db-05df}*) END;
-        curDesc[0] := curDesc[2]; (*{05e1-05e4}*)
+        curDesc.raw[0] := curDesc.raw[2]; (*{05e1-05e4}*)
       END;
-      curDesc[4] := 2; curDesc[3] := 0; g6 := 1; (*{05e5-05ec}*)
+      curDesc.raw[4] := 2; curDesc.raw[3] := 0; constMode := 1; (*{05e5-05ec}*)
     ELSE (*{05ef} '.'-field / deref tail *)
-      IF curDesc[4] # 2 THEN (*{05f1-05f3}*)
-        NormalizeOperand; curDesc[4] := 2; curDesc[3] := 0; (*{05f5-05fc}*)
+      IF curDesc.raw[4] # 2 THEN (*{05f1-05f3}*)
+        NormalizeOperand; curDesc.raw[4] := 2; curDesc.raw[3] := 0; (*{05f5-05fc}*)
       END;
       SymTabSave := SymTab.identClass; (*{05fd-0602} FIXME: no such SymTab export *)
       IF ~ MatchOpClass(1024, 3) THEN (*{0604-0608}*) END;
-      curDesc[0] := curDesc[5]; Scanner.GetSym; Scanner.NeedIdentifier; (*{0609-0612}*)
+      curDesc.raw[0] := curDesc.raw[5]; Scanner.GetSym; Scanner.NeedIdentifier; (*{0609-0612}*)
       IF Scanner.word13 (*FIXME*) # SymTabSave THEN (*{0614-0616} FIXME: word13 TBD *)
         Errors.ReportErrorWithText(2, Scanner.tokenBuffer); (*{0618-061d}*)
       END;
-      curDesc[3] := Scanner.curNode+curDesc[5]; (*{061f-0626} FIXME: word8=curNode pun *)
-      curDesc[0] := Scanner.literalType; SymTab.identClass := SymTabSave; (*{0627-062d}*)
+      curDesc.raw[3] := Scanner.curNode+curDesc.raw[5]; (*{061f-0626} FIXME: word8=curNode pun *)
+      curDesc.raw[0] := Scanner.literalType; SymTab.identClass := SymTabSave; (*{0627-062d}*)
       Scanner.GetSym; (*{062f}*)
       WHILE Scanner.curSymbol = 3 DO (*{0631-0635}*)
-        IF curDesc[3] > 510 THEN (*{063b-063d}*)
-          CodeGen.QueueConst(curDesc[3]); CodeGen.EmitTypedOp(6, 0); (*{063f-0645}*)
+        IF curDesc.raw[3] > 510 THEN (*{063b-063d}*)
+          CodeGen.QueueConst(curDesc.raw[3]); CodeGen.EmitTypedOp(6, 0); (*{063f-0645}*)
         END;
-        curDesc[3] := 0; (*{0647-0649}*)
+        curDesc.raw[3] := 0; (*{0647-0649}*)
       END;
-      g6 := 1; (*{064a-064b}*)
+      constMode := 1; (*{064a-064b}*)
     END;
     CheckAndStore; (*{064c} local proc22 *)
   END; (*{064f} back to {0519}*)
-  curDesc[1] := 1; (*{0652-0654} result flag *)
+  curDesc.raw[1] := 1; (*{0652-0654} result flag *)
 END ParseDesignatorTail;
 
 (*{0470} PROCEDURE EvalConstExpr *)
@@ -539,27 +539,27 @@ PROCEDURE EvalConstExpr;
 VAR lit: CARDINAL;
 BEGIN
   Scanner.PushWithScope; Scanner.ExpectIdentKind(4); (*{0472-0475}*)
-  curDesc[3] := Scanner.curNode; lit := Scanner.curNode; (*{0477-047f} FIXME: word8 pun *)
+  curDesc.raw[3] := Scanner.curNode; lit := Scanner.curNode; (*{0477-047f} FIXME: word8 pun *)
   IF (Scanner.followSet & 262) = 0 THEN (*{0480-0488} ident/number path *)
-    IF lit = 0 THEN curDesc[4] := 1; (*{048a-0491}*)
-    ELSIF lit = spillFlag THEN curDesc[4] := 0; (*{0493-049b} nil *)
+    IF lit = 0 THEN curDesc.raw[4] := 1; (*{048a-0491}*)
+    ELSIF lit = spillFlag THEN curDesc.raw[4] := 0; (*{0493-049b} nil *)
     ELSE
-      curDesc[2] := spillFlag-lit; curDesc[4] := 4; (*{049d-04a4} deref const *)
+      curDesc.raw[2] := spillFlag-lit; curDesc.raw[4] := 4; (*{049d-04a4} deref const *)
       IF (4 IN Scanner.followSet) & (Scanner.literalType <= 9) THEN (*{04a5-04b0}*)
-        CodeGen.SetPendingOp(1, curDesc[4], curDesc[2], curDesc[3]); (*{04b2-04b9}*)
-        curDesc[4] := 2; curDesc[3] := 0; (*{04bb-04c0}*)
+        CodeGen.SetPendingOp(1, curDesc.raw[4], curDesc.raw[2], curDesc.raw[3]); (*{04b2-04b9}*)
+        curDesc.raw[4] := 2; curDesc.raw[3] := 0; (*{04bb-04c0}*)
       END;
     END;
   ELSIF 8 IN Scanner.followSet THEN (*{04c3-04c7} cardinal const *)
-    CodeGen.QueueConst(curDesc[3]); curDesc[4] := 2; curDesc[3] := 0; g6 := 1; (*{04c9-04d4}*)
+    CodeGen.QueueConst(curDesc.raw[3]); curDesc.raw[4] := 2; curDesc.raw[3] := 0; constMode := 1; (*{04c9-04d4}*)
   ELSIF 1 IN Scanner.followSet THEN (*{04d7-04db} integer const *)
-    curDesc[2] := lit; curDesc[4] := 3; (*{04dd-04e2}*)
+    curDesc.raw[2] := lit; curDesc.raw[4] := 3; (*{04dd-04e2}*)
   ELSE (*{04e5} string/char const *)
     PushStringConst; (* local proc2 {04e9} *)
-    curDesc[4] := 2; g6 := 1; (*{04ea-04ee}*)
-    IF curDesc[3] > 510 THEN (*{04ef-04f5} long string -> static *)
-      CodeGen.QueueConst(curDesc[3]); CodeGen.EmitTypedOp(6, 0); (*{04f7-04fd}*)
-      curDesc[3] := 0; (*{04ff-0501}*)
+    curDesc.raw[4] := 2; constMode := 1; (*{04ea-04ee}*)
+    IF curDesc.raw[3] > 510 THEN (*{04ef-04f5} long string -> static *)
+      CodeGen.QueueConst(curDesc.raw[3]); CodeGen.EmitTypedOp(6, 0); (*{04f7-04fd}*)
+      curDesc.raw[3] := 0; (*{04ff-0501}*)
     END;
   END;
   CheckAndStore(Scanner.literalType, 1); (*{0502-050a} local proc22 *)
@@ -623,25 +623,25 @@ BEGIN
     CodeGen.EmitSystemCall(20); PushOperand; (*{0781-0786}*)
     IF flag # 0 THEN ParseExpression ELSE ParseDesignatorTail END; (*{0788-078e}*)
     NormalizeOperand; op := 2; m := 7; aux := lo; EmitOp; (*{078f-0797} local proc6 *)
-    CASE curDesc[0] OF (*{0798-0817} switch on type tag 90..101 *)
+    CASE curDesc.raw[0] OF (*{0798-0817} switch on type tag 90..101 *)
       90: ;
       91: ;
-      92: bad := curDesc[0] # Compiler.CharType; m := 1; (*{07a1-07a5}*)
+      92: bad := curDesc.raw[0] # Compiler.CharType; m := 1; (*{07a1-07a5}*)
         | 93..96: m := m+3; ParseTypeCast(6); (*{07a6-07af}*)
       | 97: m := 5; ParseTypeCast(11); (*{07b2-07b5}*)
-      | 98: IF curDesc[0] = Compiler.LongrealType THEN (*{07b8-07bc} LONGREAL *)
+      | 98: IF curDesc.raw[0] = Compiler.LongrealType THEN (*{07b8-07bc} LONGREAL *)
           ParseTypeCast(22); ParseTypeCast(65523);
           mod := Scanner.EnterModuleSymbol("DOUBLES", 6); (*{07c8-07d5}*)
           aux := mod; m := 14; k1 := 1; (*{07d6-07dc}*)
         ELSE ParseTypeCast(13); ParseTypeCast(65531); m := 6; (*{07df-07e6}*)
         END;
-      | 101: IF ~ IsPointer(curDesc[0]) THEN bad := TRUE END; (*{07ea-07ef}*)
+      | 101: IF ~ IsPointer(curDesc.raw[0]) THEN bad := TRUE END; (*{07ea-07ef}*)
         EmitAddress; op := 3; m := 2; (*{07f0-07f6}*)
       ELSE bad := TRUE; (*{0817}*)
     END;
     IF bad THEN (*{0819-082d} elem/type mismatch *)
-      IF curDesc[0] # 0 THEN
-        Errors.ReportErrorWithText(curDesc[0]+7, curDesc[0]);
+      IF curDesc.raw[0] # 0 THEN
+        Errors.ReportErrorWithText(curDesc.raw[0]+7, curDesc.raw[0]);
       ELSE Errors.ReportErrorWithText(hi, "this type"); (*{082f-0843}*)
       END;
     END;
@@ -711,12 +711,12 @@ END ExpandStdProc43;
 PROCEDURE ExpandStdProc44(first: CARDINAL);
 VAR save: CARDINAL;
 BEGIN
-  save := curDesc[3]; (*{08e6-08e8}*)
+  save := curDesc.raw[3]; (*{08e6-08e8}*)
   IF Scanner.AcceptSymbol(1) THEN (*{08e9-08ec}*)
     PushOperand; (*{08ee}*)
     IF ~ MatchOpClass(1024, 1) THEN (*{08f1-08f5}*) END;
     IF first # 0 THEN CentralError(63) END; (*{08f6-08fd} GetConstVal guard *)
-    GetConstVal; ConstToCard(curDesc[2], 1); (*{08fe-0902}*)
+    GetConstVal; ConstToCard(curDesc.raw[2], 1); (*{08fe-0902}*)
     LOOP (*{0903-0912} ','-separated consts *)
       IF first # 0 THEN CentralError(63) END; (*{090a-0911}*)
       GetConstVal;
@@ -756,11 +756,11 @@ END ExpandStdProc45;
 (*{09a2} PROCEDURE ExpandStdProc46() — MIN/MAX-operand validator *)
 PROCEDURE ExpandStdProc46;
 BEGIN
-  IF (48 IN curDesc[4]) OR ((curDesc[4] = 2) & (Compiler.rangeCheckEnabled # 0)) THEN (*{09a4-09b3}*)
-    IF (curDesc[4] # 5) OR (curDesc[0] # 1) THEN CentralError(96) END; (*{09b5-09c0}*)
-    NormalizeOperand; curDesc[4] := 2; curDesc[3] := 0; (*{09c3-09ca}*)
+  IF (48 IN curDesc.raw[4]) OR ((curDesc.raw[4] = 2) & (Compiler.rangeCheckEnabled # 0)) THEN (*{09a4-09b3}*)
+    IF (curDesc.raw[4] # 5) OR (curDesc.raw[0] # 1) THEN CentralError(96) END; (*{09b5-09c0}*)
+    NormalizeOperand; curDesc.raw[4] := 2; curDesc.raw[3] := 0; (*{09c3-09ca}*)
   END;
-  IF curDesc[4] = 2 THEN CodeGen.EmitStandardOp(8) END; (*{09cb-09d2} ORD-class emit *)
+  IF curDesc.raw[4] = 2 THEN CodeGen.EmitStandardOp(8) END; (*{09cb-09d2} ORD-class emit *)
   PushOperand; (*{09d4-09dc} copy desc, push *)
 END ExpandStdProc46;
 
@@ -788,14 +788,14 @@ BEGIN
                 ParseExpression; ConstToCard(Compiler.CardType, t2);
               ELSE CodeGen.QueueConst(1); (*{0a29-0a2a}*)
               END;
-              IF buf.raw[0] = 0 THEN curDesc[0] := Compiler.CardType ELSE curDesc[0] := buf.raw[0] END; (*{0a2c-0a3b}*)
+              IF buf.raw[0] = 0 THEN curDesc.raw[0] := Compiler.CardType ELSE curDesc.raw[0] := buf.raw[0] END; (*{0a2c-0a3b}*)
               IF curDesc.raw[4] = 0 THEN EmitOp ELSE EmitOp END; (*{0a3d-0a4d} proc6/7 *)
               curDesc.raw[1] := 2; PushExprDesc; PopOperand; (*{0a4e-0a56} proc5/3 FIXME arity *)
           | 98, 99:
               ParseDesignatorTail;
               IF ~ MatchOpClass(16, t2) THEN (*{0a59-0a5d}*) END;
               ExpandStdProc46; Scanner.ExpectSymbol(1); (*{0a5d-0a60}*)
-              ParseExpression; ConstToCard(buf.raw[0], curDesc[2]); ConstToCard(buf.raw[0], curDesc[2]); (*{0a62-0a6a}*)
+              ParseExpression; ConstToCard(buf.raw[0], curDesc.raw[2]); ConstToCard(buf.raw[0], curDesc.raw[2]); (*{0a62-0a6a}*)
               CodeGen.EmitStandardOp(5); (*{0a6b-0a6d}*)
               EmitTypedOp(4, t3-2); PopOperand; (*{0a6f-0a77} proc6/3 *)
           | 100: Errors.ReportError(34); (*{0a78-0a7a} illegal *)
@@ -811,7 +811,7 @@ BEGIN
               IF ~ MatchOpClass(388, t2) THEN (*{0aa4-0aa8}*) END;
               IF t3 # 4 THEN CodeGen.EmitTypedOp(13+t3, k); (*{0aac-0ab2}*)
               ELSE
-                m := curDesc[0]; (*{0ab6-0ab8}*)
+                m := curDesc.raw[0]; (*{0ab6-0ab8}*)
                 IF k = 0 THEN ConstToCard(Compiler.IntType, t2) END; (*{0aba-0ac0}*)
                 CodeGen.EmitTypedOp(12, k); (*{0ac1-0ac5}*)
               END;
@@ -826,12 +826,12 @@ BEGIN
             save5 := CodeGen.emitEnabled; CodeGen.emitEnabled := 0; (*{0add-0ae1} FIXME: no word5 export *)
             ParseDesignatorTail; CodeGen.emitEnabled := save5; (*{0ae3-0ae5}*)
             IF ~ MatchOpClass(2048, t2) THEN (*{0ae7-0aeb}*) END;
-            IF curDesc[2] = 0 THEN EmitAddress (*{0aec-0af4} local proc28 *)
-            ELSE CodeGen.QueueConst(curDesc[2]); (*{0af7-0afd}*)
+            IF curDesc.raw[2] = 0 THEN EmitAddress (*{0aec-0af4} local proc28 *)
+            ELSE CodeGen.QueueConst(curDesc.raw[2]); (*{0af7-0afd}*)
             END;
         | 100: ParseDesignatorTail; (*{0b00} CAP-class? *)
-            IF g6 # 0 THEN (*{0b01}*)
-            ELSIF curDesc[4] > 9 THEN CentralError(97); (*{0b02-0b0b}*)
+            IF constMode # 0 THEN (*{0b01}*)
+            ELSIF curDesc.raw[4] > 9 THEN CentralError(97); (*{0b02-0b0b}*)
             END;
             NormalizeOperand; (*{0b0c-0b0e}*)
         | 101, 102:
@@ -847,7 +847,7 @@ BEGIN
         | 103..105:
             Scanner.PushWithScope; Scanner.ExpectIdentKind(3); (*{0b34-0b37}*)
             t4 := Scanner.literalType; (*{0b39-0b3b}*)
-            curDesc[0] := t2; (*{0b3c-0b3e}*)
+            curDesc.raw[0] := t2; (*{0b3c-0b3e}*)
             IF t3 = 13 THEN (*{0b3f-0b43} VAL-class *)
               IF ~ MatchOpClass(7, t2) THEN (*{0b44-0b47}*) END;
               Scanner.GetSym; Scanner.ExpectSymbol(1); (*{0b47-0b4b}*)
@@ -870,7 +870,7 @@ BEGIN
     END;
   ELSE (*{09f4} non-set head already handled above; join *)
   END;
-  curDesc[0] := t4; (*{0bcc-0bce} publish result type *)
+  curDesc.raw[0] := t4; (*{0bcc-0bce} publish result type *)
 END ParseSetOrCastTail;
 (* EXPRESS group 3 — @0bd2..1516: operands, relations, simple expr,
    ParseExpression, const/type getters, assignment, init *)