adapted to the new GetFuncInfo() specification

This commit is contained in:
Celestino Amoroso 2024-04-26 04:36:03 +02:00
parent 761ec868e6
commit d354102c6a
4 changed files with 6 additions and 9 deletions

View File

@ -11,9 +11,7 @@ import (
// -------- function call term // -------- function call term
func newFuncCallTerm(tk *Token, args []*term) *term { func newFuncCallTerm(tk *Token, args []*term) *term {
return &term{ return &term{
tk: *tk, tk: *tk,
// class: classVar,
// kind: kindUnknown,
parent: nil, parent: nil,
children: args, children: args,
position: posLeaf, position: posLeaf,
@ -44,7 +42,7 @@ func evalFuncCall(parentCtx ExprContext, self *term) (v any, err error) {
} }
// Export functions // Export functions
for _, refName := range ctx.EnumFuncs(func(name string) bool { return exportAll || name[0] == '@' }) { for _, refName := range ctx.EnumFuncs(func(name string) bool { return exportAll || name[0] == '@' }) {
if info := ctx.GetFuncInfo(refName); info != nil { if info, _ := ctx.GetFuncInfo(refName); info != nil {
exportFunc(parentCtx, refName, info) exportFunc(parentCtx, refName, info)
} }
} }

View File

@ -25,8 +25,7 @@ func evalVar(ctx ExprContext, self *term) (v any, err error) {
var exists bool var exists bool
name := self.source() name := self.source()
if v, exists = ctx.GetVar(name); !exists { if v, exists = ctx.GetVar(name); !exists {
info := ctx.GetFuncInfo(name) if info, exists := ctx.GetFuncInfo(name); exists {
if info != nil {
v = info.Functor() v = info.Functor()
} else { } else {
err = fmt.Errorf("undefined variable or function %q", name) err = fmt.Errorf("undefined variable or function %q", name)

View File

@ -50,8 +50,8 @@ func (ctx *SimpleFuncStore) Clone() ExprContext {
} }
} }
func (ctx *SimpleFuncStore) GetFuncInfo(name string) (info ExprFunc) { func (ctx *SimpleFuncStore) GetFuncInfo(name string) (info ExprFunc, exists bool) {
info, _ = ctx.funcStore[name] info, exists = ctx.funcStore[name]
return return
} }

View File

@ -54,7 +54,7 @@ func (ctx *SimpleVarStore) EnumVars(acceptor func(name string) (accept bool)) (v
return return
} }
func (ctx *SimpleVarStore) GetFuncInfo(name string) (f ExprFunc) { func (ctx *SimpleVarStore) GetFuncInfo(name string) (f ExprFunc, exists bool) {
return return
} }