ソースを参照

feat(express): verify proc20 exact; converging IF/ELSE (no mid-returns), OR, DEC, REPEAT-extra

Eric Streit 2 週間 前
親
コミット
966372c5c9
1 ファイル変更、7 行追加、9 行削除
  1. 7 9
      src/compiler/EXPRESS.MOD

+ 7 - 9
src/compiler/EXPRESS.MOD

@@ -396,7 +396,7 @@ BEGIN
   IF CARDINAL(sel^.w5) = CARDINAL(Compiler.WordType) THEN
     IF LookupField(RecordPtr(t)) THEN
       flags := CARDINAL(t^.w5^.word3);
-      IF LookupField(t^.w5) AND ODD(flags) THEN
+      IF LookupField(t^.w5) OR ODD(flags) THEN
         LoadIndirect(curDesc);
         CodeGen.QueueConst(1);
         CodeGen.EmitTypedOp(7, 0);
@@ -409,7 +409,6 @@ BEGIN
         CodeGen.QueueConst((flags - 1) DIV 2);
         CodeGen.EmitTypedOp(6, 0);
       END;
-      RETURN;
     ELSIF (t^.w4 <= 9) THEN
       IF needVal THEN
         CentralError((CARDINAL(t^.w3) <> 1) OR (curDesc^.kind <> 5), 95);
@@ -420,17 +419,16 @@ BEGIN
       END;
     END;
     CodeGen.QueueConst((CARDINAL(t^.w3) - 1) DIV 2);
-    RETURN;
-  END;
-  (*{0634}*) (* REPEAT match-loop *)
+  ELSE (*{0634}*) (* REPEAT match-loop *)
   REPEAT
     MatchOpClass(BITSET{11}, base);
     EmitAddress(curDesc);
     sel := NodePtr(sel^.w5);
     curDesc^.typ := NodePtr(curDesc^.typ^.w5);
+    DEC(curDesc^.extra, 2);
   UNTIL NOT LookupField(RecordPtr(sel));
   CentralError(sel = curDesc^.typ, 64);
-  RETURN;
+  END;
   ELSE (*{0659}*) (* not-found path *)
   CheckAndStore(sel);
   IF needVal THEN
@@ -440,14 +438,14 @@ BEGIN
                  OR (((RecordPtr(sel) = Compiler.WordType) OR (RecordPtr(sel) = Compiler.ByteType))
                      AND (CARDINAL(t^.w3) <= 2)), 65);
     CentralError((CARDINAL(t^.w3) <> 1) OR (curDesc^.kind <> 5), 95);
-    RETURN;
   ELSE
     IF (RecordPtr(t) = Compiler.charArrayDesc) AND IsPointer(RecordPtr(sel)) THEN
       CentralError((Scanner.StrLen(curDesc^.value, 128) - 1)
                    = (sel^.w2^.high - sel^.w2^.low), 45);
-    END;
+    ELSE
     ConstToInt(sel, base);
     PopExprDesc(RecordPtr(sel));
+    END;
   END;
   END;
 END ParseSelector;
@@ -475,7 +473,7 @@ BEGIN
           IF 8 IN Scanner.scanOpt THEN (*{0561}*)
             EmitAddress(curDesc); CodeGen.QueueConst(0); CodeGen.EmitStandardOp(0); (*{0567-056d}*)
           END;
-          buf.extra := buf.extra-2; (*{0570-0575}*)
+          DEC(buf.extra, 2); (*{0570-0575}*)
         ELSE (*{0578} typed actual *)
           ConstToInt(savedTyp^.word2, 44); PopExprDesc(savedTyp^.word2); (*{0579-057f}*)
           CodeGen.QueueConst(CARDINAL(savedTyp^.word2^.word5)); CodeGen.EmitTypedOp(7, 0); (*{0580-0587}*)