|
|
@@ -1,5 +1,30 @@
|
|
|
# Analysis — adding generics to m2compiler-V3
|
|
|
|
|
|
+> **Update 2026-10-08 (branch `generics-inc1`).** Two things changed
|
|
|
+> since this analysis: (1) V3 now **has an AST** and `Lower` emits from
|
|
|
+> it, so the "V3 has no AST" premise in §3 is stale — though the
|
|
|
+> substitution-scope re-parse is still the pragmatic route, because the
|
|
|
+> AST stores **resolved `TypeIndex`**, not type names; (2) the chosen
|
|
|
+> syntax is the **ISO 10514-2 refinement form** (`GENERIC … MODULE` +
|
|
|
+> `MODULE X = G(args)`), per `../Generics/m2generic-syntaxe-analysis.md`,
|
|
|
+> not `IMPORT X<T>`.
|
|
|
+>
|
|
|
+> **Done (Increment 1, commit `e1d0472`):** grammar recognition of the
|
|
|
+> four module categories — `GENERIC DEFINITION/IMPLEMENTATION MODULE`
|
|
|
+> with TYPE formals, and refining `DEFINITION/IMPLEMENTATION MODULE
|
|
|
+> X = G(actuals)`. Formals are entered as unresolved alias types
|
|
|
+> (`SymTab.EnterTypeParam`); refinements are recorded. A refinement
|
|
|
+> still produces an empty module.
|
|
|
+>
|
|
|
+> **Next (Increment 2):** instantiate by **re-parsing the generic source
|
|
|
+> with a substitution scope**, driven by a driver session pre-pass —
|
|
|
+> record each generic's def/impl file path; on a refinement, re-open the
|
|
|
+> generic, bind the formals to the actuals, name the module `X`, dedup,
|
|
|
+> and lower it before the importer. Requires moving the normal body's
|
|
|
+> `BeginDef` into the `;` branch (so the refinement does not
|
|
|
+> pre-register `X`), a `SymTab.EnterTypeParamBound`, a grammar
|
|
|
+> instantiation context + accessors, and driver re-parse logic.
|
|
|
+
|
|
|
Study reviewed: `../Generics/` (the three `m2-generics-coco-r-*.md`
|
|
|
analyses, the `m2generic/` prototype: `M2Generic.atg`,
|
|
|
`gm2-gcc-0.2.atg` → `gm2-gcc-generics-0.3.atg`, `src/GenericGen.mod`,
|