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

@ -15,8 +15,6 @@ export property UiEnv {
ctx: UiEnv = null # what a <provide> above gave, seen through components too
inst: UiInst = null # the Ludic component whose template this is
}
var ui_view: UiView = null
var ui_errs: []string = new []string
function env_new(parent: UiEnv) -> UiEnv {
let e = new UiEnv
@ -33,7 +31,7 @@ function env_bind(e: UiEnv, name: string, v: Val) -> void {
push(e.names, name)
push(e.vals, v)
}
function env_get(e: UiEnv, name: string) -> Val {
function env_get(ui_st: mut UiState, e: UiEnv, name: string) -> Val {
var at = e
while at != null {
var i = len(at.names) - 1
@ -52,11 +50,11 @@ function env_get(e: UiEnv, name: string) -> Val {
cx = cx.parent
}
if e.model != null and Value.has(e.model, name) != 0 { return Value.get(e.model, name) }
ui_err(`no {name} here: not a loop's, a prop, a state or in the view`)
ui_err(ui_st, `no {name} here: not a loop's, a prop, a state or in the view`)
return Value.null()
}
# `set name = value`: the nearest component's state of that name, or <state> that holds it
function env_set(e: UiEnv, name: string, v: Val) -> void {
function env_set(ui_st: mut UiState, e: UiEnv, name: string, v: Val) -> void {
var at = e
while at != null {
if at.inst != null {
@ -70,18 +68,17 @@ function env_set(e: UiEnv, name: string, v: Val) -> void {
}
at = at.parent
}
ui_err(`set {name}: no state here holds it - declare it with <state {name}="..."/>`)
ui_err(ui_st, `set {name}: no state here holds it - declare it with <state {name}="..."/>`)
}
# an error is said once, however many frames make it, and names the template line being built
var ui_at: string = ""
# said by the runtime, or by a host about something a template asked for
export function ui_err(msg0: string) -> void {
export function ui_err(ui_st: mut UiState, msg0: string) -> void {
var msg = msg0
if ui_at != "" and not ui_has(msg, ".xml:") { msg = `{ui_at}: {msg}` }
for i in 0 .. len(ui_errs) {
if ui_errs[i] == msg { return }
if ui_st.ui_at != "" and not ui_has(msg, ".xml:") { msg = `{ui_st.ui_at}: {msg}` }
for i in 0 .. len(ui_st.ui_errs) {
if ui_st.ui_errs[i] == msg { return }
}
push(ui_errs, msg)
push(ui_st.ui_errs, msg)
print(`ui: {msg}`)
}
function ui_has(s: string, part: string) -> bool {
@ -92,4 +89,4 @@ function ui_has(s: string, part: string) -> bool {
return false
}
# every error said so far - for a host to show them where a developer will see them
export function ui_errors() -> []string { return ui_errs }
export function ui_errors(ui_st: UiState) -> []string { return ui_st.ui_errs }