Since now builtin functions are registared in a new global context. This reduces the effort to copy the whole set of builtin functions in the context of a function call; only the called function will be copied, if it is global.

This commit is contained in:
2024-05-11 10:45:38 +02:00
parent 0a9543543d
commit 50e7168214
6 changed files with 88 additions and 31 deletions
+2 -2
View File
@@ -24,8 +24,8 @@ func newVarTerm(tk *Token) *term {
func evalVar(ctx ExprContext, self *term) (v any, err error) {
var exists bool
name := self.source()
if v, exists = ctx.GetVar(name); !exists {
if info, exists := ctx.GetFuncInfo(name); exists {
if v, exists = GetVar(ctx, name); !exists {
if info, exists, _ := GetFuncInfo(ctx, name); exists {
v = info.Functor()
} else {
err = fmt.Errorf("undefined variable or function %q", name)