Ver código fonte

feat(express): verify proc5/32/33/34 exact via ZZ + IN-order fix

PopExprDesc v2 (guard-IF, CentralError, IF/ELSE, OR-assign) scores
153/153 SAME (nested IsOrdinal incl.); IsSet 51/51, BaseTypeOf 54/54.
IN operator pushes left-to-right: field IN BITSET(n) (not n IN ...).
score.py: allow spaces around colon in heads.
Eric Streit 2 semanas atrás
pai
commit
f8b76adcb1
2 arquivos alterados com 21 adições e 28 exclusões
  1. 20 27
      src/compiler/EXPRESS.MOD
  2. 1 1
      tools/score.py

+ 20 - 27
src/compiler/EXPRESS.MOD

@@ -198,33 +198,29 @@ VAR
 
 BEGIN
   (*{0318}*) (* only descriptors with kind-bit 7 set need pop work *)
-  IF NOT (7 IN BITSET(d^.word4)) THEN RETURN END;
+  IF d^.word4 IN BITSET(7) THEN
   (*{0320}*) (* classify *)
-  isOrd := ORD(IsOrdinal(d^.word0));
+  isOrd := ORD(IsOrdinal(d));
   neg := INTEGER(isOrd) < 0;
-  hasRange := 3 IN BITSET(d^.word4);
+  hasRange := d^.word4 IN BITSET(3);
   IF hasRange THEN lo := CARDINAL(d^.word5); hi := CARDINAL(d^.high) END;
-  (*{0336}*) (* constant-expression branch *)
+  (*{0336}*) (* constant-expression branch vs codegen branch *)
   IF curDesc^.mode = 0 THEN
     IF neg THEN
-      IF (RecordPtr(curDesc^.typ) = Compiler.IntType) OR (INTEGER(curDesc^.value) >= 0) THEN
-        Errors.ReportError(70);
-      END;
-      IF hasRange AND (INTEGER(curDesc^.value) >= lo) AND (INTEGER(curDesc^.value) <= hi) THEN
-        Errors.ReportError(72);
+      CentralError((RecordPtr(curDesc^.typ) = Compiler.IntType)
+                   OR (INTEGER(curDesc^.value) >= 0), 70);
+      IF hasRange THEN
+        CentralError((INTEGER(curDesc^.value) >= lo)
+                     AND (INTEGER(curDesc^.value) <= hi), 72);
       END;
     ELSE
-      IF RecordPtr(curDesc^.typ) <> Compiler.IntType THEN
-        Errors.ReportError(71);
-      END;
-      IF hasRange AND (CARDINAL(curDesc^.value) >= CARDINAL(lo))
-         AND (CARDINAL(curDesc^.value) <= CARDINAL(hi)) THEN
-        Errors.ReportError(72);
+      CentralError(RecordPtr(curDesc^.typ) <> Compiler.IntType, 71);
+      IF hasRange THEN
+        CentralError((CARDINAL(curDesc^.value) >= CARDINAL(lo))
+                     AND (CARDINAL(curDesc^.value) <= CARDINAL(hi)), 72);
       END;
     END;
-    RETURN;
-  END;
-  (*{0378}*) (* codegen branch, range-check flag bit 8 *)
+  ELSE (*{0378}*) (* codegen branch, range-check flag bit 8 *)
   IF 8 IN Scanner.scanOpt THEN
     emitConv := FALSE;
     IF ABS(INTEGER(ORD(IsOrdinal(RecordPtr(curDesc^.typ))) - isOrd)) = 2 THEN
@@ -236,14 +232,10 @@ BEGIN
       emitConv := emitConv OR (sub^.word4 > 1);
       IF NOT emitConv THEN
         IF neg THEN
-          IF (INTEGER(sub^.word5) < lo) OR (INTEGER(sub^.high) > hi) THEN
-            emitConv := TRUE;
-          END;
+          emitConv := (INTEGER(sub^.word5) < lo) OR (INTEGER(sub^.high) > hi);
         ELSE
-          IF (CARDINAL(sub^.word5) < CARDINAL(lo))
-             OR (CARDINAL(sub^.high) > CARDINAL(hi)) THEN
-            emitConv := TRUE;
-          END;
+          emitConv := (CARDINAL(sub^.word5) < CARDINAL(lo))
+                      OR (CARDINAL(sub^.high) > CARDINAL(hi));
         END;
       END;
       IF emitConv THEN
@@ -254,6 +246,7 @@ BEGIN
       END;
     END;
   END;
+  END;
 END PopExprDesc;
 
 (* proc33 @03d5 (REV @017d) — ~IsSet: single OR-chain (MCD orjp-threaded,
@@ -265,9 +258,9 @@ BEGIN
       OR ((t2^.word4 = 1) AND IsSet(t2^.word2, t1))
       OR ((t1^.word4 = 1) AND IsSet(t2, t1^.word2))
       OR ((t2 = Compiler.AddressType) AND (t1 = Compiler.CardType))
-      OR (96 IN BITSET(t1^.word4))
+      OR (t1^.word4 IN BITSET(96))
       OR ((t1 = Compiler.AddressType) AND (t2 = Compiler.CardType))
-      OR (96 IN BITSET(t2^.word4));
+      OR (t2^.word4 IN BITSET(96));
 END IsSet;
 
 (* proc34 @041d (REV @01c5) — ~BaseTypeOf: single OR-chain.

+ 1 - 1
tools/score.py

@@ -6,7 +6,7 @@ import re, sys
 def procs(path, mod):
     txt = open(path, errors='replace').read()
     heads = [(m.group(1), int(m.group(2), 16))
-             for m in re.finditer(r'(?m)^;? ?' + mod + r'\.(\w+): ([0-9a-f]{4})$', txt)]
+             for m in re.finditer(r'(?m)^;? ?' + mod + r'\.(\w+)\s*: ([0-9a-f]{4})$', txt)]
     ops = []
     for line in txt.splitlines():
         m = re.match(r'^\s*([0-9a-f]{4})\s+((?:[0-9a-f]{2}\s*)+?)(?:\s{2,}|\t+|$)(.*)$', line)