Quellcode durchsuchen

feat(express): proc15 to 233/236 (WHILE, REPEAT-UNTIL, INC, CheckAndStore-VALUE)

Remaining proc15 delta is ONLY the temp-reserve prologue (HeadPtr
locals have no reserve source under retail strictness; Borland-lax
record-to-pointer suspected, like SYM v2/v3 skew). CheckAndStore
takes VALUE ADDRESS (proc20 ADR-free, proc15 direct). Identifier
block is REPEAT-UNTIL curSym<>3. INC-by-variable gives dup.
Eric Streit vor 2 Wochen
Ursprung
Commit
aa3ef0484c
1 geänderte Dateien mit 20 neuen und 20 gelöschten Zeilen
  1. 20 20
      src/compiler/EXPRESS.MOD

+ 20 - 20
src/compiler/EXPRESS.MOD

@@ -133,9 +133,9 @@ BEGIN HALT; END ParseActualList;
 (* proc28 @009e — ~EmitAddress (takes head). *)
 PROCEDURE EmitAddress(d: HeadPtr);
 BEGIN HALT; END EmitAddress;
-(* proc22 stub — ~CheckAndStore (VAR ADDRESS takes any pointer var,
-   probed: HeadPtr + NodePtr vars; TBD by MCD audit). *)
-PROCEDURE CheckAndStore(VAR a: ADDRESS);
+(* proc22 stub — ~CheckAndStore (VALUE ADDRESS: proc20 passes ADR(sel),
+   proc15 passes curDesc pointer; TBD by MCD audit). *)
+PROCEDURE CheckAndStore(a: ADDRESS);
 BEGIN HALT; END CheckAndStore;
 
 PROCEDURE PushExprDesc(dst: HeadPtr; src: DescPtr);
@@ -301,7 +301,7 @@ BEGIN
 END FoldConstOp;
 
 (* proc7 @04cd (REV @0275) — ~ConstToCard: big-OR IF-THEN. c is a TYPE
-   node (callers pass CardType/buf.typ: RecordPtr); word0/word4/word2. *)
+   node (callers pass CardType/buf^.typ: RecordPtr); word0/word4/word2. *)
 PROCEDURE ConstToCard(c: RecordPtr; errPos: CARDINAL);
 BEGIN
   (*{04cd}*)
@@ -454,12 +454,11 @@ END ParseSelector;
 
 (*{0510} PROCEDURE ParseDesignatorTail *)
 PROCEDURE ParseDesignatorTail;
-VAR buf: Head; more: BOOLEAN; savedTyp: RecordPtr;
+VAR buf: HeadPtr; more: BOOLEAN; savedTyp: RecordPtr; (* FIXME-RESERVE: MCD reserves but no source; see notes *)
 BEGIN
-  buf := curDesc^; constMode := 0; EvalConstExpr; (*{0512-0517}*)
-  LOOP
-    IF (Scanner.curSym # 3) & ((Scanner.curSym-44) > 5) THEN EXIT END; (*{0519-0525}*)
-    IF Scanner.AcceptSy(44) THEN (*{0528-052b} '(' actuals/indexqual *)
+  constMode := 0; EvalConstExpr; (*{076d} no buf copy here *)
+  WHILE (Scanner.curSym = 3) OR ((Scanner.curSym - 44) IN BITSET(5)) DO (*{0771}*)
+    IF Scanner.AcceptSy(44) THEN (*{0780} '(' actuals/indexqual *)
       NormalizeOperand(curDesc); (*FIXME-ARG*) more := FALSE; (*{052e-0530}*)
       LOOP
         MatchOpClass(BITSET{11}, 44); (*{0538}*)
@@ -467,19 +466,19 @@ BEGIN
           EmitAddress(curDesc); CodeGen.QueueConst(1);
           CodeGen.EmitTypedOp(6, 0); CodeGen.EmitTypedOp(8, 0); (*{053e-054a}*)
         END;
-        buf := curDesc^; BoolCondHelper; savedTyp := RecordPtr(buf.typ); (*{054c-0550}*)
-        IF CARDINAL(buf.typ^.w2) = 0 THEN (*{0554-0556} typeless actual *)
+        buf^ := curDesc^; BoolCondHelper; savedTyp := RecordPtr(buf^.typ); (*{054c-0550}*)
+        IF CARDINAL(savedTyp^.word2) = 0 THEN (*{0554-0556} typeless actual *)
           ConstToInt(Compiler.CardType, 44); PopExprDesc(Compiler.CardType); (*{0559-055e}*)
           IF 8 IN Scanner.scanOpt THEN (*{0561}*)
-            EmitAddress(curDesc); CodeGen.QueueConst(0); CodeGen.EmitStandardOp(0); (*{0567-056d}*)
+            EmitAddress(buf); CodeGen.QueueConst(0); CodeGen.EmitStandardOp(0); (*{07bf} buf-area *)
           END;
-          DEC(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}*)
         END;
         IF more THEN CodeGen.EmitTypedOp(6, 0) END; (*{0589-058e}*)
-        curDesc^ := buf; (*{0590-0592}*)
+        curDesc^ := buf^; (*{0590-0592}*)
         curDesc^.typ := NodePtr(savedTyp^.word5); (*{07ec}*)
         Scanner.TestSet(BITSET{1,6}); (*{07f0} statement, no result *)
         IF Scanner.AcceptSy(6) THEN (*{07f4}*)
@@ -496,26 +495,27 @@ BEGIN
       END;
       IF RecordPtr(curDesc^.typ) = Compiler.AddressType THEN curDesc^.typ := NodePtr(Compiler.WordType) ELSE (*{05cd-05d9}*)
         MatchOpClass(BITSET{5}, 46); (*{05db-05df}*)
-        curDesc^.typ := NodePtr(curDesc^.value); (*{05e1-05e4}*)
+        curDesc^.typ := NodePtr(curDesc^.typ^.w2); (*{0838} unwrap *)
       END;
       curDesc^.kind := 2; curDesc^.extra := 0; constMode := 1; (*{05e5-05ec}*)
     ELSE (*{05ef} '.'-field / deref tail *)
       IF curDesc^.kind <> 2 THEN (*{05f1-05f3}*)
         NormalizeOperand(curDesc); curDesc^.kind := 2; curDesc^.extra := 0; (*{05f5-05fc}*)
       END;
+      REPEAT (*{0855-088d} qualified-name loop *)
       scopeSave^.link0 := ADDRESS(SymTab.currentScope); (*{0855-0858} stash *)
-      scopeSave := SymTab.T1(SymTab.currentScope); (*{0859-085a} redirect to slot *)
+      SymTab.currentScope := ADDRESS(scopeSave); (*{0859-085a} redirect to slot *)
       MatchOpClass(BITSET{10}, 3); (*{085c-0860}*)
       scopeSave^.link1 := ADDRESS(curDesc^.typ^.w5); (*{0861-0865} *)
       Scanner.GetSym; Scanner.NeedID; (*{0866-0868}*)
       IF Scanner.scopeCur <> scopeSave THEN (*{086a-086e}*)
         Errors.ReportErrorWithText(2, Scanner.tokBuf); (*{0870-0875}*)
       END;
-      curDesc^.extra := curDesc^.extra + CARDINAL(Scanner.curNode^.word5); (*{0877-087e}*)
+      INC(curDesc^.extra, CARDINAL(Scanner.curNode^.word5)); (*{0877-087e}*)
       curDesc^.typ := NodePtr(Scanner.litType); (*{087f-0882}*)
       SymTab.currentScope := ADDRESS(scopeSave^.link0); (*{0883-0885} restore *)
       Scanner.GetSym; (*{0887}*)
-      (*{0889} loop-back on curSym=3 to scopeSave block: outer LOOP (audit) *)
+      UNTIL Scanner.curSym <> 3; (*{0889} *)
       IF curDesc^.extra > 510 THEN (*{088f-0895}*)
         CodeGen.QueueConst(curDesc^.extra); CodeGen.EmitTypedOp(6, 0);
       END;
@@ -523,8 +523,8 @@ BEGIN
       constMode := 1; (*{08a2-08a3}*)
     END;
     CheckAndStore(curDesc); (*{08a4} *)
-  END; (*{064f} back to {0519}*)
-  curDesc^.mode := 1; (*{0652-0654} result flag *)
+  END;
+  curDesc^.mode := 1; (*{08aa} no-selector exit *)
 END ParseDesignatorTail;
 
 (*{0470} PROCEDURE EvalConstExpr *)