wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run

ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 5ffe50ed02
commit 19fcf60599
459 changed files with 17862 additions and 17603 deletions

View file

@ -1,34 +1,32 @@
# state.ludic - a component's or a screen's own values, <state name="{first}"/>, kept from frame
# to frame by where the instance is in the tree, and set by `set name = value`
var st_keys: []string = new []string
var st_vals: []Val = new []Val
function st_for(key: string, t: UiTpl, e: UiEnv) -> Val {
function st_for(ui_st: mut UiState, key: string, t: UiTpl, e: UiEnv) -> Val {
var decl: UiTpl = null
for i in 0 .. len(t.kids) {
if t.kids[i].tag == "state" { decl = t.kids[i] }
}
if decl == null { return null }
for i in 0 .. len(st_keys) {
if st_keys[i] == key { return st_vals[i] }
for i in 0 .. len(ui_st.st_keys) {
if ui_st.st_keys[i] == key { return ui_st.st_vals[i] }
}
let o = Value.object()
for i in 0 .. len(decl.keys) { Value.put(o, decl.keys[i], ui_eval(decl.vals[i], e)) }
push(st_keys, key)
push(st_vals, o)
for i in 0 .. len(decl.keys) { Value.put(o, decl.keys[i], ui_eval(ui_st, decl.vals[i], e)) }
push(ui_st.st_keys, key)
push(ui_st.st_vals, o)
return o
}
# a screen's state starts again the next time it opens
export function ui_forget(screen: string) -> void {
export function ui_forget(ui_st: mut UiState, screen: string) -> void {
let keys = new []string
let vals = new []Val
for i in 0 .. len(st_keys) {
let k = st_keys[i]
for i in 0 .. len(ui_st.st_keys) {
let k = ui_st.st_keys[i]
let mine = len(k) >= len(screen) and k[0..len(screen)] == screen and (len(k) == len(screen) or k[len(screen)] == 47)
if not mine {
push(keys, k)
push(vals, st_vals[i])
push(vals, ui_st.st_vals[i])
}
}
st_keys = keys
st_vals = vals
ui_st.st_keys = keys
ui_st.st_vals = vals
}