summary_two-phase-slice7.md 1.5 KB

Two-phase refactor — slice 7 (unit root + builtin statements)

Branch ast-stage-c. Suite 178/178; self-hosting fixpoint OK (3,016,802 bytes; slice 6 was 3,007,851).

What landed

Unit root

A module-level astUnit now holds NkUnit(name, decls, body) for DEFINITION, IMPLEMENTATION and program modules. decls is the unit's NkDeclSeq (from DeclSeq) and body is the program/init NkBlock (or NoNode). ProgModule and ImplUnit also reset astStmt/ astDecl at entry, so the root never picks up a stale node.

Builtin statements

INCL/EXCL, INC/DEC, NEW and DISPOSE now build NkCalls whose callee is an NkIdent naming the builtin, with the designator (and step/element expression) as children. Node-building is inserted as extra actions around the existing emit actions, which are unchanged.

Verified (temporary AST.Dump of astUnit, then removed)

VAR x : INTEGER; s : BITSET; p : POINTER TO INTEGER;
BEGIN
  INC(x); INCL(s, 1); NEW(p); DISPOSE(p)
END

produced

NkUnit(Ident unitdump, NkDeclSeq[NkVarDecl x/s/p], NkBlock[ NkCall(INC, x), NkCall(INCL, s, 1), NkCall(NEW, p), NkCall(DISPOSE, p) ])

with each NkVarDecl carrying its ty index.

Deliberately deferred

  • Imports (NkImport), CLASS items, nested modules in the unit AST.
  • CASE and WITH statements.
  • Brace/set literals and ResultComp call suffixes.
  • Lower + .ssa byte-compare.

Next

CASE/WITH; imports/CLASS; brace/set literals; then the Lower walk.