feat(ecs): engine-owned systems auto-tick user components (#43)
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 18s
ci / build-and-test (push) Successful in 1m17s
commit-lint / conventional-commits (push) Successful in 4s
docs / build-and-deploy (push) Successful in 20s

Adds the ECS hook issues #43 and #47 named as their real dependency: a
system the *engine* owns, inserted into the frame loop over a component a
game merely declares and carries — no `handler` wired.

- runtime/native/systems.ludic: esys_spriteanim (SpriteAnim frame advance:
  loop/once/pingpong) and esys_motion (Motion value tween: linear/in/out/
  in-out), both on the by-name reflection ABI, integer + deterministic.
- backend: emit_engine_systems_for_phase inserts the calls after every user
  handler in a phase (auto-loop and the drivable tick helpers alike);
  uses_engine_systems() drives the systems.ludic splice, the world-table
  force-emit, and makes a component-only game count as a systems game.
- A game that declares neither component is byte-for-byte unchanged.

Worked example + regression: examples/library/anim_ecs.ludic. Full suite
73 passed, self-host C-free bootstrap fixpoint intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-08-31 15:41:44 +03:00
parent 9452557f3c
commit b0143337d9
10 changed files with 15109 additions and 14658 deletions

View file

@ -407,6 +407,7 @@ var g_uses_reflect: bool = false # a program mentioned Reflect.* -> force-emit
var g_uses_light: bool = false # a program mentioned Light.* -> splice the 2D light pass
var g_uses_value: bool = false # Value.*/Json.*/Reflect.serialize -> splice the value tree + JSON (#44)
var g_uses_reflect_io: bool = false # Reflect.serialize/apply -> splice the reflection serializer
var g_uses_esys: bool = false # an engine-owned system component (SpriteAnim/Motion/Light2D) is declared -> splice systems.ludic + force the reflection ABI
function already_loaded(full: pointer) -> bool {
var i = 0
@ -603,6 +604,18 @@ function maybe_splice_runtime() -> void {
do_import("runtime/native/reflect_io.ludic")
cur_dir = saved
}
# engine-owned systems (#43/#47): a game that declares a well-known engine
# component (SpriteAnim / Motion / Light2D / Occluder) gets systems.ludic
# spliced, and the compiler inserts a call to each esys_* at its frame phase
# (emit_engine_systems_for_phase). The systems read/write components through the
# reflection ABI, so g_uses_esys also force-emits the world table (emit_decl).
# Light2D/Occluder additionally consume the 2D light pass, so pull it in too.
if uses_engine_systems() {
g_uses_esys = true
cur_dir = ""
do_import("runtime/native/systems.ludic")
cur_dir = saved
}
}
function parse_program() -> void {
@ -623,6 +636,7 @@ function parse_program() -> void {
g_uses_regex = false
g_uses_query = false
g_uses_reflect = false
g_uses_esys = false
g_uses_light = false
g_uses_value = false
g_uses_reflect_io = false