session-2026-09-22-step4.md 3.1 KB

Session save — 2026-09-22 (m2compiler-V3, step 4 complete)

Where we are

HEAD: abc41a7 — tag v3-step4.3, milestone tag v3-step4. Suite 87/87 (44 run — incl. 4 trap-aborts + 4 sessions — + 43 reject). Build is warning-free (only the known-benign Coco TypeBlock LL(1) advisory). Tree clean except untracked git.txt (push recipe, intentional). No remote configured.

Step 4 in three landings (all green at each tag)

  • v3-step4.1 (79/79) — calls: value/VAR params, function results, recursion, FORWARD, open-array VAR formals, int→real argument conversion; frames with entry copies and stack-slot locals; 233 invalid call. Two backend bugs fixed: nested-call state clobber (16-deep call stack) and uninitialized stack slots (zero-init locals).
  • v3-step4.2 (82/82) — nested procedures: static-link display (alloc8 link records, chain walking for up-level load/store/ address), lexical ProcDepthOf; bare P; parameterless calls. QBE can't nest definitions, so nested bodies hoist via per-nesting-depth buffers (nestBufs).
  • v3-step4.3 (87/87) — separate compilation: single-image sessions (lib.def lib.mod prog.mod → one <Prog>.ssa), module registry + scopes, FROM/IMPORT, qualified L.x via materialization, opaque TYPE T; completion, module BEGIN as <mod>_init called from main, whole-image buffering written under the program module's name.

Locked decisions from this session (do not relitigate)

  • Whole-program single-image separate compilation (V1/V2 lineage), not per-file objects; program module is last in the session.
  • Unknown modules import as silent stubs; a known module's missing export is 201; a session with no program module is an error.
  • Opaque types complete via SetTarget on the definition's alias; clients use them behind pointers only.
  • Mangled symbols are <proc>_<uid> (uid per compilation); definitions and implementations agree because the implementation resumes the definition's proc node (ResumeProc).
  • DISPOSE nils and is shallow; nil-deref raw; classic idents.

Step 4 deferred (carry forward)

Strict 231 signature checking for impl-vs-def headings (arity is checked; parameter/result types are not), procedure-type variables and indirect calls, HIGH/LEN, variant records, import cycles, class lowering (vtable/THIS), enum literals, F()^ result suffixes, >64 locals, recursive DISPOSE.

Next: step 5 — Benjamin stdlib

Per docs/plan.md and the Blaise map (docs/blaise-phases-map.md): stdlib/ with classic DEFINITION/IMPLEMENTATION + OPAQUE forms (no R10 INTERFACE/blueprints/operator-procedures), semantics from Benjamin/Actual/m2bsk-master/r10/stdlib/*.if: Strings, TextIO (+ UWrite*), WholeIO, Math, Files, over runtime/syslib (SysIO/Storage). This is the first phase that exercises the new separate-compilation machinery with real libraries.

Resume commands

cd /home/eric/Projets/Projets-Modula2/MyWork/m2compiler-V3/compiler
./build.sh && ./run_tests.sh   # expect 87/87, zero gm2 warnings