compiler(0.R): a dispatched action's record is the queue's to keep - one list per action, filled in place, all free again when the drain ends

dispatch lowered to ludic_act_push(k, new A { ... }): a fresh record every dispatch, and an input
system dispatches Move and FrameTime every frame. The queue now keeps a list per action
(kept<k>, used<k>); ludic_act_new__A hands out the next (made only when all are queued), new's
emitter fills it field by field as it fills a fresh one (every field, default or given), and
drain_actions sets every used<k> back to 0 once the queue is empty. A reducer only ever reads
its action during the drain, so nothing sees a record after it is reused. Actions are visible
to the program's file, where the queue lives, as reducers already were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 02:02:11 +03:00
parent 3e3c6088fb
commit 93bc8a90db
4 changed files with 65 additions and 7 deletions

View file

@ -23,14 +23,16 @@ function rec_field(rec: Node, fname: pointer) -> Node {
# `new T` / `new T { field: value, ... }` — allocate a record and seed each
# field: a value from the override record if given, else the field's declared
# default. `rec` is the E_REC of overrides (or null for the bare `new T`).
function emit_new_struct(name: pointer, rec: Node) -> Val {
# `into`: a record to fill in place of a fresh one (a dispatch's, kept by the action queue)
function emit_new_struct(name: pointer, rec: Node, into: Node) -> Val {
let s = layout_node(name) # a struct or a property — same shape
if (s == null) and port_find(name) >= 0 { perr(`{name} is a port: it is filled once with 'bind {name} {{ ... }}' where the program is put together, not made with new`) }
if (s == null) { perr(`unknown record type {name} in new`) }
vis_check(s, name)
let lty = layout_ty(name)
let sz = emit_sizeof(lty)
let obj = emit_bind(`call ptr @malloc(i64 {sz})`)
var obj = ""
if into != null { obj = emit_expr(into).code } else { obj = emit_bind(`call ptr @malloc(i64 {sz})`) }
var f = 0
while f < len(s.kids) {
let fd = s.kids[f]