summary_two-phase-slice10.md 1.7 KB

Two-phase refactor — slice 10 (ResultComp + unbounded sequences)

Branch ast-stage-c. Suite 178/178; self-hosting fixpoint OK (3,027,925 bytes; slice 9 was 3,024,098).

What landed

Call-result suffixes (ResultComp)

F()[i], F().f, F()^ now wrap the call in an NkDesignator with NkSelector children (SelIndex/SelField/SelDeref), exactly like Design. Fact builds the NkCall right after ArgList into a local astRes and passes it by reference to ResultComp, which wraps it on the first suffix and appends each selector.

Unbounded block / decl sequences

Found while dumping t_resultsfx.mod: NkBlock/NkDeclSeq were capped at AST.MaxChild (8) children, so a body with more than 7 statements silently dropped the rest. Fixed with a chunked sequence:

  • a new module-level AstAppend(kind, VAR head, tail, item) appends up to MaxChild-1 items per node and chains the overflow through child[MaxChild-1] into a fresh node of the same kind;
  • StatSeq, DeclSeq, ConstBlock, VarBlock now use it.

Sequences are therefore unbounded; a walk reads children 0..MaxChild-2 then follows child[MaxChild-1].

Verified (temporary AST.Dump, then removed)

  • GetRec()^.a → NkDesignator(NkCall(GetRec), SelDeref, SelField a).
  • A body with 12 assignments produced 12 NkAssign nodes across 2 NkBlock chunks (7 + 5) — nothing dropped.

Deliberately deferred

  • Imports, CLASS, nested modules in the unit AST.
  • Lower + .ssa byte-compare.
  • The same MaxChild cap still applies to CASE arms, WITH designators and call actuals — worth the chunked treatment later.

Next

Imports / CLASS / nested modules, then Lower.