summary_two-phase-slice11.md 1.2 KB

Two-phase refactor — slice 11 (imports)

Branch ast-stage-c. Suite 178/178; self-hosting fixpoint OK (3,032,308 bytes; slice 10 was 3,027,925).

What landed

NkImport nodes. Import builds a node whose child 0 is the FROM module (NkIdent) and whose following children are the imported names; a plain IMPORT collects the module names as children. ImpList/ImpName/ImpModList take the node as a parameter and append to it. The module-level astImp/astImpTail accumulator collects the imports of a unit; each NkUnit stores them as child 3.

AST.IsLeafKind no longer lists NkImport, so a tree walk recurses into its NkIdent children instead of mis-reading child 0 as a text index.

Verified (temporary AST.Dump, then removed)

FROM TestIO IMPORT WriteString, WriteLn;

gave NkUnit(impdump, decls, body, imports=NkDeclSeq[ NkImport(NkIdent TestIO, NkIdent WriteString, NkIdent WriteLn) ]).

Deliberately deferred

  • CLASS / CLASS IMPLEMENTATION items and nested modules in the unit AST.
  • Lower + .ssa byte-compare.
  • The MaxChild cap still applies to CASE arms, WITH designators and call actuals.

Next

CLASS/nested modules (or move to Lower).