ludic.ui: an unmounted component is mounted again rather than made again - its record renewed (a generated renew), its props and model kept; an action's call answers into a ring

A prompt that comes and goes as a player walks (co-op's netleak: in_get, cmp_*_new, bd_class, value_slot/put)
made a new record, props and model on every mount, and an action's call answered into a new Val (ev_call_with).
examples/library/ui_remount: two thousand comings and goings hold the heap at 0, and the counter starts at 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 15:25:55 +03:00
parent fc0f3d3790
commit 6cdef20cc2
14 changed files with 46052 additions and 45244 deletions

View file

@ -16,8 +16,9 @@ function cm_class(c: int, px: pointer, head: Node) -> void {
} else { lss = cm_lss_inline(c, lss, dir, 0) }
var src = `function {px}class() -> UiClass {{\n let k = new UiClass\n k.name = "{name}"\n`
src = src + ` k.xml_path = "{xml_path}"\n k.xml = {px}xml_text()\n k.lss_path = "{lss_at}"\n k.lss = {px}lss_text()\n`
src = src + ` k.make = fn {px}new\n k.props = fn {px}props\n k.model = fn {px}model\n k.call = fn {px}call\n return k\n}}\n`
src = src + ` k.make = fn {px}new\n k.renew = fn {px}renew\n k.props = fn {px}props\n k.model = fn {px}model\n k.call = fn {px}call\n return k\n}}\n`
vw_parse(src, g_cm_file[c], g_cm_line[c], head.vis)
vw_parse(cm_renew_src(c, px, "Cmp" + name), g_cm_file[c], g_cm_line[c], head.vis)
cm_text_fn(c, px + "xml_text", xml, head)
cm_text_fn(c, px + "lss_text", lss, head)
let reg = node(E_CALL)
@ -87,3 +88,26 @@ function cm_unique(name: pointer) -> void {
i += 1
}
}
# an instance's record put back as `new` made it, for ludic.ui to mount again rather than make another:
# each field its default, or its type's zero
function cm_renew_src(c: int, px: pointer, rec: pointer) -> pointer {
var src = `function {px}renew(p: pointer) -> void {{\n let s: {rec} = p\n`
var i = 0
while i < len(g_cm_keep[c]) {
let f = g_cm_keep[c][i]
if g_cm_defs[c][i] != null {
src = src + ` s.{f} = {px}def_{f}(s)\n`
} else {
src = src + ` s.{f} = {cm_zero(g_cm_keep_ty[c][i])}\n`
}
i += 1
}
return src + "}\n"
}
function cm_zero(ty: pointer) -> pointer {
if ty == "int" or ty == "long" or ty == "byte" { return "0" }
if ty == "float" { return "0.0" }
if ty == "fixed" { return "fixed(0)" }
if ty == "bool" { return "false" }
return "null"
}