Bläddra i källkod

feat(express): verify proc13/14; GetTypeDesc export; scorer target mask

Eric Streit 2 veckor sedan
förälder
incheckning
b5b61bccf5
4 ändrade filer med 31 tillägg och 24 borttagningar
  1. 3 0
      SESSION.md
  2. 1 0
      src/compiler/EXPRESS.DEF
  3. 26 23
      src/compiler/EXPRESS.MOD
  4. 1 1
      tools/score.py

+ 3 - 0
SESSION.md

@@ -314,3 +314,6 @@ Next: GENZ80 media hunt; stage-2 pty-driven MCD diff per module.
   MOD 256->AND 255 peepholes discovered; LoadAddr+indexed-byte has no
   retail-legal spelling (transfer-index/deref are syntax bans) — accepted
   Borland-internal-laxity delta. Endianness: byte[1]=high (LE Z80).
+- Verified now 32: + proc13 GetConstVal (9/9), proc14 GetTypeDesc (60/60).
+  proc14 has no internal callers -> added to DEF exports (PASS1-called).
+  Plain ^ derefs (no view pun). score.py: mask all 4-hex targets.

+ 1 - 0
src/compiler/EXPRESS.DEF

@@ -71,6 +71,7 @@ PROCEDURE NormalizeOperand(d: HeadPtr);
 PROCEDURE LoadIndirect(d: Head);
 PROCEDURE BoolCondHelper;
 PROCEDURE GetConstVal;
+PROCEDURE GetTypeDesc(t: RecordPtr; lo: ADDRESS; hi: ADDRESS);
 PROCEDURE OpSetTest(allowed: BITSET; errCode: CARDINAL);
 PROCEDURE ConstToCard(c: RecordPtr; errPos: CARDINAL);
 PROCEDURE ConstToInt(c: ADDRESS; ctx: ADDRESS);

+ 26 - 23
src/compiler/EXPRESS.MOD

@@ -90,7 +90,7 @@ PROCEDURE IsSet(t2, t1: Compiler.RecordPtr): BOOLEAN; FORWARD;
 PROCEDURE BaseTypeOf(t2, t1: Compiler.RecordPtr): BOOLEAN; FORWARD;
 PROCEDURE CheckAssignable; FORWARD;
 PROCEDURE ParseSelector(sel: NodePtr; needVal: BOOLEAN; base: CARDINAL); FORWARD;
-PROCEDURE GetTypeDesc(src: ADDRESS; dest: ADDRESS; mode: CARDINAL); FORWARD;
+PROCEDURE GetTypeDesc(t: RecordPtr; lo: ADDRESS; hi: ADDRESS); FORWARD;
 PROCEDURE CheckAssignmentCompat(dst: ADDRESS); FORWARD;
 
 (* EXPRESS group 1 — descriptors, predicates, const-fold, designator base, selector *)
@@ -1550,33 +1550,36 @@ BEGIN
   curDesc^.typ := Compiler.BooleanType; (* BOOLEAN result *) (*{13df-13e2} *)
 END ParseExpression;
 
+(* proc13 @164b — ~GetConstVal: check constant context, drop pending load. *)
 PROCEDURE GetConstVal;
 BEGIN
-  BoolCondHelper; (* proc12 *) (*{13f5}*)
-  IF curDesc^.mode # 0 THEN Errors.ReportError(25) END; (*{13f6-13fb}*)
-  CodeGen.DiscardPending; (*{13fc-13fe}*)
+  BoolCondHelper; (* proc12 *)
+  CentralError(curDesc^.mode = 0, 25);
+  CodeGen.DiscardPending;
 END GetConstVal;
 
-PROCEDURE GetTypeDesc(src: ADDRESS; dest: ADDRESS; mode: CARDINAL);
+(* proc14 @1658 — ~GetTypeDesc: read subrange bound(s) of type t into
+   lo/hi buffers (called from PASS1 declarations; no internal callers).
+   Buffers are plain ADDRESS derefs (no view pun). *)
+PROCEDURE GetTypeDesc(t: RecordPtr; lo: ADDRESS; hi: ADDRESS);
 BEGIN
-  GetConstVal; (* proc13 *) (*{1402}*)
-  EmitOp(); (* proc6 *) (*{1403}*)
-  ConstToCard(src, 0); (* proc7 *) (*{1404-1406} FIXME: (c,errPos) vs call shape *)
-  PopExprDesc(src); (* proc5 FIXME: DescPtr vs ADDRESS *)
-  IF (curDesc^.typ # Compiler.CardType) OR (curDesc^.value < 0) THEN
-    Errors.ReportError(80); (*{1409-1416} *)
-  END;
-  Words(dest)^[0] := curDesc^.value; (*{1417-141e} FIXME pun *)
-  IF Scanner.AcceptSy(4) THEN (* ',' second bound *) (*{141f-1422}*)
-    GetConstVal; (*{1424}*)
-    EmitOp(); (*{1426}*)
-    ConstToCard(src, 0); (*{1427-0429} *)
-    PopExprDesc(src); (*{042a} *)
-    IF (curDesc^.typ # Compiler.CardType) OR (curDesc^.value < 0) THEN
-      Errors.ReportError(80); (*{142b-1438} *)
-    END;
-    IF curDesc^.value < Words(dest)^[0] THEN Errors.ReportError(46) END; (*{143a-1440} FIXME *)
-    Words(dest)^[0] := curDesc^.value; (*{1441-1444} upper bound *)
+  GetConstVal; (* proc13 *)
+  Proc6;
+  ConstToCard(t, 0); (* proc7 *)
+  PopExprDesc(t); (* proc5 *)
+  CentralError((RecordPtr(curDesc^.typ) <> Compiler.CardType)
+               OR (INTEGER(curDesc^.value) >= 0), 80);
+  lo^ := CARDINAL(curDesc^.value);
+  hi^ := lo^;
+  IF Scanner.AcceptSy(4) THEN (* ',' second bound *)
+    GetConstVal;
+    Proc6;
+    ConstToCard(t, 0);
+    PopExprDesc(t);
+    CentralError((RecordPtr(curDesc^.typ) <> Compiler.CardType)
+                 OR (INTEGER(curDesc^.value) >= 0), 80);
+    CentralError(INTEGER(curDesc^.value) >= INTEGER(lo^), 46);
+    hi^ := CARDINAL(curDesc^.value);
   END;
 END GetTypeDesc;
 

+ 1 - 1
tools/score.py

@@ -22,7 +22,7 @@ def procs(path, mod):
     return out
 
 def norm(m):
-    m = re.sub(r'\b0[0-9a-f]{3}\b', '@@@@', m)
+    m = re.sub(r'\b[0-9a-f]{4}\b', '@@@@', m)
     m = re.sub(r'call_with_frame proc\d+', 'call_with_frame proc##', m)
     m = re.sub(r'nested_call proc\d+', 'nested_call proc##', m)
     m = re.sub(r'(?<!_)proc\d+', 'proc##', m)