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:
Martino Ferrari
2026-06-24 14:53:40 +02:00
parent 3ddffc14d7
commit 519c1f2df4
4 changed files with 446 additions and 66 deletions
+4 -2
View File
@@ -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