context clone & export function moved from operand-func.go to context-helpers.go

This commit is contained in:
2024-04-26 20:12:56 +02:00
parent 107ec4958f
commit d2bab5fd9e
2 changed files with 30 additions and 13 deletions
+2 -13
View File
@@ -22,7 +22,7 @@ func newFuncCallTerm(tk *Token, args []*term) *term {
// -------- eval func call
func evalFuncCall(parentCtx ExprContext, self *term) (v any, err error) {
ctx := parentCtx.Clone()
ctx := cloneContext(parentCtx)
name, _ := self.tk.Value.(string)
params := make([]any, len(self.children))
for i, tree := range self.children {
@@ -34,18 +34,7 @@ func evalFuncCall(parentCtx ExprContext, self *term) (v any, err error) {
}
if err == nil {
if v, err = ctx.Call(name, params); err == nil {
exportAll := isEnabled(ctx, control_export_all)
// Export variables
for _, refName := range ctx.EnumVars(func(name string) bool { return exportAll || name[0] == '@' }) {
refValue, _ := ctx.GetVar(refName)
exportVar(parentCtx, refName, refValue)
}
// Export functions
for _, refName := range ctx.EnumFuncs(func(name string) bool { return exportAll || name[0] == '@' }) {
if info, _ := ctx.GetFuncInfo(refName); info != nil {
exportFunc(parentCtx, refName, info)
}
}
exportObjects(parentCtx, ctx)
}
}
return