wip(0.S3): calls into the runtime get its states supplied; the emitter's own calls to runtime functions reach their thunks; the migration names the runtime's states per file

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:44:50 +03:00
parent a476ec7976
commit d70b00f30d
15 changed files with 54328 additions and 53309 deletions

View file

@ -137,7 +137,7 @@ function emit_tween_ns(meth: pointer, e: Node) -> Val {
# a call into tween.ludic; the 2-arg Tween.done(timer, dur) is the pure form.
if (len(e.kids) == 1) {
let h = emit_expr(e.kids[0])
return val(emit_bind(`call i32 @fn_tween_done(i32 {h.code})`), "bool")
return val(emit_bind(`call i32 {fn_sym("tween_done")}(i32 {h.code})`), "bool")
}
let timer = emit_expr(e.kids[0]); let dur = emit_expr(e.kids[1]) # timer >= duration -> bool
let c = emit_bind(`icmp sge i32 {timer.code}, {dur.code}`)

View file

@ -56,17 +56,17 @@ function emit_ivec_ns(meth: pointer, e: Node) -> Val {
if (meth == "heading") { # degrees from a to b (0 = +x, 90 = +y)
if find_fn("rt_ivec_heading") == null { perr("IVec2.heading needs the engine runtime") }
let a = emit_expr(e.kids[0]); let b = emit_expr(e.kids[1])
return val(emit_bind(`call i32 @fn_rt_ivec_heading(i64 {a.code}, i64 {b.code})`), "int")
return val(emit_bind(`call i32 {fn_sym("rt_ivec_heading")}(i64 {a.code}, i64 {b.code})`), "int")
}
if (meth == "along") { # the point `distance` along `degrees` from origin
if find_fn("rt_ivec_along") == null { perr("IVec2.along needs the engine runtime") }
let o = emit_expr(e.kids[0]); let d = emit_expr(e.kids[1]); let n = emit_expr(e.kids[2])
return val(emit_bind(`call i64 @fn_rt_ivec_along(i64 {o.code}, i32 {d.code}, i32 {n.code})`), "IVec2")
return val(emit_bind(`call i64 {fn_sym("rt_ivec_along")}(i64 {o.code}, i32 {d.code}, i32 {n.code})`), "IVec2")
}
if (meth == "step") { # a -1/0/1 unit step along `degrees`
if find_fn("rt_ivec_step") == null { perr("IVec2.step needs the engine runtime") }
let d = emit_expr(e.kids[0])
return val(emit_bind(`call i64 @fn_rt_ivec_step(i32 {d.code})`), "IVec2")
return val(emit_bind(`call i64 {fn_sym("rt_ivec_step")}(i32 {d.code})`), "IVec2")
}
if (meth == "add") { # component-wise a + b
let a = emit_expr(e.kids[0]); let b = emit_expr(e.kids[1])

View file

@ -70,11 +70,11 @@ function emit_takeright(elt: pointer, mode: int, fnsym: pointer, keyll: pointer,
return emit_bind(`icmp slt {elt} {bv}, {av}`) # right strictly less than left
}
if (mode == SORT_WITH) {
let c = emit_bind(`call i32 @fn_{fnsym}({elt} {av}, {elt} {bv})`)
let c = emit_bind(`call i32 {fn_sym(fnsym)}({elt} {av}, {elt} {bv})`)
return emit_bind(`icmp sgt i32 {c}, 0`) # cmp(left, right) > 0 -> left comes after
}
let kl = emit_bind(`call {keyll} @fn_{fnsym}({elt} {av})`)
let kr = emit_bind(`call {keyll} @fn_{fnsym}({elt} {bv})`)
let kl = emit_bind(`call {keyll} {fn_sym(fnsym)}({elt} {av})`)
let kr = emit_bind(`call {keyll} {fn_sym(fnsym)}({elt} {bv})`)
if (mode == SORT_KEY_DESC) {
return emit_bind(`icmp slt {keyll} {kl}, {kr}`) # desc: right first when its key is larger
}
@ -232,7 +232,7 @@ function emit_list_ns(meth: pointer, e: Node) -> Val {
let pool = emit_expr(e.kids[0])
let cnt = emit_expr(e.kids[1])
if find_fn("rt_list_sample") == null { perr("List.sample needs the engine runtime (a game, or import ludic.core)") }
return val(emit_bind(`call ptr @fn_rt_list_sample(ptr {pool.code}, i32 {cnt.code})`), "[]int")
return val(emit_bind(`call ptr {fn_sym("rt_list_sample")}(ptr {pool.code}, i32 {cnt.code})`), "[]int")
}
let s = emit_expr(e.kids[0])
if not is_slice_ty(s.ty) { perr(`List.{meth} needs a slice`) }