wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters

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 3eda72e8c2
commit 5ffe50ed02
463 changed files with 72045 additions and 67421 deletions

View file

@ -15,6 +15,8 @@ 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
@ -31,7 +33,7 @@ function env_bind(e: UiEnv, name: string, v: Val) -> void {
push(e.names, name)
push(e.vals, v)
}
function env_get(ui_st: mut UiState, e: UiEnv, name: string) -> Val {
function env_get(e: UiEnv, name: string) -> Val {
var at = e
while at != null {
var i = len(at.names) - 1
@ -50,11 +52,11 @@ function env_get(ui_st: mut UiState, 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(ui_st, `no {name} here: not a loop's, a prop, a state or in the view`)
ui_err(`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(ui_st: mut UiState, e: UiEnv, name: string, v: Val) -> void {
function env_set(e: UiEnv, name: string, v: Val) -> void {
var at = e
while at != null {
if at.inst != null {
@ -68,17 +70,18 @@ function env_set(ui_st: mut UiState, e: UiEnv, name: string, v: Val) -> void {
}
at = at.parent
}
ui_err(ui_st, `set {name}: no state here holds it - declare it with <state {name}="..."/>`)
ui_err(`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(ui_st: mut UiState, msg0: string) -> void {
export function ui_err(msg0: string) -> void {
var msg = msg0
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 }
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 }
}
push(ui_st.ui_errs, msg)
push(ui_errs, msg)
print(`ui: {msg}`)
}
function ui_has(s: string, part: string) -> bool {
@ -89,4 +92,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(ui_st: UiState) -> []string { return ui_st.ui_errs }
export function ui_errors() -> []string { return ui_errs }