ludic.ui: props kept an instance, a call's arguments a depth, a loop's index shared, an absent attribute's text without a Value; runtime Value.clear - benchmark 36 -> 20 KB a frame
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
46888b6716
commit
51a5e06f5c
10 changed files with 43 additions and 5 deletions
|
|
@ -34,8 +34,18 @@ function ui_eval(ui_st: mut UiState, x: UiExpr, e: UiEnv) -> Val {
|
|||
}
|
||||
# a call: len() and range() are the template's own, anything else is the view's
|
||||
function ev_call(ui_st: mut UiState, x: UiExpr, e: UiEnv) -> Val {
|
||||
let args = Value.list()
|
||||
let depth = ui_st.ev_depth
|
||||
while len(ui_st.ev_args) <= depth { push(ui_st.ev_args, Value.list()) }
|
||||
let args = ui_st.ev_args[depth]
|
||||
Value.clear(args)
|
||||
ui_st.ev_depth = depth + 1
|
||||
for i in 0 .. len(x.args) { Value.add(args, ui_eval(ui_st, x.args[i], e)) }
|
||||
let r = ev_call_with(ui_st, x, e, args)
|
||||
ui_st.ev_depth = depth
|
||||
return r
|
||||
}
|
||||
# the call itself, its arguments evaluated; a callee reads them and keeps none
|
||||
function ev_call_with(ui_st: mut UiState, x: UiExpr, e: UiEnv, args: Val) -> Val {
|
||||
if x.s == "len" and len(x.args) == 1 { return Value.int(Value.count(Value.at(args, 0))) }
|
||||
if x.s == "range" and len(x.args) == 1 {
|
||||
let out = Value.list()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue