فهرست منبع

docs: Lower L6 status (nested modules done; imports blocked by session model; classes next)

Eric Streit 6 روز پیش
والد
کامیت
b81a7257ae
1فایلهای تغییر یافته به همراه46 افزوده شده و 0 حذف شده
  1. 46 0
      docs/summary_lower_l6.md

+ 46 - 0
docs/summary_lower_l6.md

@@ -0,0 +1,46 @@
+# Lower phase — L6 status (2026-10-05)
+
+Branch **`ast-stage-c`**.  L6 = "classes/vtables, imports, nested modules".
+
+## Landed
+
+**Nested modules** (`f82f72b`, tag `v3-lower6-nested`)
+- `CanDecl` accepts a nested `NkUnit` (with no imports).
+- `LowerDecls` emits the nested unit's declarations and, when it has a
+  `BEGIN` body, `BeginInit`/body/`EndInit` (registering `<nested>_init`
+  so the enclosing `BeginBody` calls it).
+- `ReenterGlobals` re-registers a nested module's non-exported globals in
+  the still-open enclosing module scope, so `QbeGen.GlobalRef` resolves
+  their `"<outer>_<name>"` symbols after the nested scope has been popped.
+- `lower_ok t_nestedmod.mod` byte-matches.  Suite 194/194; FIXPOINT OK
+  (3,328,857 bytes).
+
+## Blocked / remaining
+
+### Imports — blocked by the session-image model
+`-lower` is invoked only from `ProgModule`'s END (`M2.atg`), so Lower
+re-emits **only the last unit**.  But a session's image is accumulated
+across all units (`sessBuf`): a program that `IMPORT`s a module pulls
+that module's procs/init/globals into the *same* `gen_ssa/<Prog>.ssa`.
+So re-emitting just the program cannot byte-match.
+
+Supporting imports therefore needs a **mechanism change**: lower *every*
+unit (definition/implementation/program) and accumulate a session image
+(mirroring `sessBuf`), or otherwise compare per unit.  That is the same
+mechanism the **L7 flip** needs, so it is the natural next structural
+step.  Qualified names (`M.x`) additionally need `SymTab.MaterializeAlias`
+at lowering time (module scope is open — workable) and qualified-call
+resolution in `LowerCall` (currently `CalleeName` reads only the base
+ident).
+
+### Classes/vtables — large, single-unit, verifiable
+Surface: `NkClassDecl`/`NkFieldDecl`, `CLASS IMPLEMENTATION`, method
+binding (`obj.Method` + `ArmRecv`), virtual dispatch, inheritance, `NEW`
+for classes, vtables (`QbeGen.EmitVTables`), `THIS`.  Independent of
+imports, so it can be byte-verified with `lower_ok` on a self-contained
+class program.
+
+## Suggested order
+1. Classes/vtables (verifiable now).
+2. The per-unit lowering mechanism (unblocks imports and is the L7
+   prerequisite).