controllogic: make expr evaluator value-polymorphic (arrays, indexing, array funcs)
Rewrites internal/controllogic/expr.go to evaluate to Value (scalar float64 or []Value array): adds array literals [a,b], postfix indexing arr[i], and array functions (len, sum, mean, push, pop, slice, concat, sort, …). Resolver type changes from func(...) float64 to func(...) Value; EvalValue added; EvalExpr/EvalBool retain scalar float64/bool returns. Three temporary shims added in engine.go, lua.go, and expr_test.go pending Tasks 4 and 6. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -61,8 +61,10 @@ func (lr *luaRuntime) ensure() error {
|
||||
target := s.CheckString(1)
|
||||
ds, name, ok := parseRef(target)
|
||||
var v float64
|
||||
if ok && lr.curResolve != nil {
|
||||
v = lr.curResolve(ds, name)
|
||||
if ok && lr.curResolve != nil { // shim: Task 6 finalizes lua Value handling
|
||||
if f, fok := lr.curResolve(ds, name).(float64); fok {
|
||||
v = f
|
||||
}
|
||||
}
|
||||
s.Push(lua.LNumber(v))
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user