فهرست منبع

docs: expressions are the front-end constant evaluator, not just inline emit

Eric Streit 4 روز پیش
والد
کامیت
d6f7657a45
1فایلهای تغییر یافته به همراه21 افزوده شده و 5 حذف شده
  1. 21 5
      docs/STATUS.md

+ 21 - 5
docs/STATUS.md

@@ -113,17 +113,33 @@ Done:
    `HALT`.
 
 Still to do:
-3. Expressions / `Fact` / `Term` (the big one: `CopyOp`, `IntStr`,
-   `Op3*`, `WidenLong`, `Cmp*`, `AddrOf*`, `Set*`, folding), and
-   designators.
-4. Calls (`ArgList`/`ActParam`), declarations/proc headings,
-   imports, classes.
+3. **Expressions / `Fact` / `Term` / `SimExpr` / `Expr`: BLOCKED.**
+   Their `QbeGen` calls are not (only) inline emit — they are the
+   front-end **constant evaluator**.  `Expr`'s `q` is handed to
+   `SymTab.SetSymVal` and `Lower.NoteConstVal` for a CONST, and
+   `Lower` re-emits the constant from it (`Lower.mod:2499`,
+   `IsImm(qv)` → `DeclConst`); `QbeGen.ConstInt` likewise needs a
+   folded literal for BY/THEN/array bounds.  Removing `Fold2`/`CopyOp`/
+   `Op3`/`NewTemp` there would break constants and constant-bound
+   checks.  Deleting them requires first teaching `Lower` to fold
+   constants itself from the AST (a real change, not cleanup), then
+   dropping the grammar's value layer.  Designators are entangled the
+   same way (`qn`/`NoteAddr` feed VAR-actual addresses).
+4. Calls (`ArgList`/`ActParam`), declarations/proc headings, imports,
+   classes: the call/decl results are runtime values, not constants,
+   so their emission (`CallBegin`/`CallEnd`/`CallArg`/`BeginFunc`/
+   `FuncParam`/`EndFunc`/`Mangled`/`DeclVar`/`DeclConst`/…) can be
+   deleted while keeping the `SymTab` checks.
 5. Retire the `-lower` test flag and the now-degenerate byte-compare
    tests in `run_tests.sh`.
 6. Remove the dead scaffolding: `LowerSession`, `MaterializeGlobals`,
    `SaveSession`/`RestoreSession` and the `SetNoEmit` machinery (once
    nothing emits inline), plus the dead `SetLower`/`lowerRequested`.
 
+Note: full deletion to zero is gated on moving constant folding into
+`Lower` (item 3).  Until then the expression/value layer stays.
+
+
 ## Are we near completion?
 
 - **Of the working compiler:** yes — it is done, green, and