feat(compiler): dynamic system registration + --emit-module for binary packages (#64)

The runtime + compiler foundation for prebuilt binary packages, over the
existing reflection C-ABI (EV0–EV8 already gives dynamic components via
ludic_register_prop).

- ludic_register_system(fn, phase) + a registry the frame loop dispatches after
  each phase's own handlers — the systems analogue of ludic_register_prop,
  mirroring the EV6 foreign event-listener array. Emitted for every ECS program;
  a zero-length registry means a non-hosting game is output-identical.
- --emit-module: compile a package to a position-independent module — no main,
  no world table — that declares the host reflection ABI it calls and carries a
  load-time constructor which registers its @System(Phase) functions and runs
  module_init (where it registers its dynamic components). Built as a dylib with
  -undefined dynamic_lookup, it binds ludic_* back to the host image at load.
- @System(Phase) annotation marks a module function as a runtime-registered
  system; the compiler supplies its address (Ludic source cannot take one).
- The reflection ABI (world table) is now emitted for every ECS program, so any
  game can host binary modules with no flag; unused defs dead-strip at -O2, so
  golden renders stay byte-identical and the C-free bootstrap fixpoint holds.

Proven end-to-end: a module dylib registers a component + an Update system; a
host game that never saw its source links it and the system mutates the shared
world each frame. Full suite 87/0, test-tools 30/0, fixpoint intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-01 07:44:18 +03:00
parent 035e6dfe41
commit e1537d2d45
7 changed files with 18543 additions and 17872 deletions

View file

@ -89,6 +89,7 @@ entry {
else { if (a == ("--windowed")) { want = 1 }
else { if (a == ("--headless")) { want = 2 }
else { if (a == ("--emit-llvm")) { emit_ir = true }
else { if (a == ("--emit-module")) { g_emit_module = true; emit_ir = true } # issue #64: prebuilt binary module IR
else { if (a == ("--fmt")) { fmt = true }
else { if (a == ("--save-temps")) { save = true }
else { if (a == ("--run")) { run = true }
@ -101,7 +102,7 @@ entry {
let m = `ludicc: ignoring unknown flag {a}\n`
file_write(file_stderr(), m, len(m))
} else { path = a }
} } } } } } } } }
} } } } } } } } } }
ai = ai + 1
}