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
func newFuncCallTerm(tk *Token, args []*term) *term {
return &term{
tk: *tk,
// class: classVar,
// kind: kindUnknown,
tk: *tk,
parent: nil,
children: args,
position: posLeaf,
@ -44,7 +42,7 @@ func evalFuncCall(parentCtx ExprContext, self *term) (v any, err error) {
}
// Export functions
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)
}
}

View File

@ -25,8 +25,7 @@ func evalVar(ctx ExprContext, self *term) (v any, err error) {
var exists bool
name := self.source()
if v, exists = ctx.GetVar(name); !exists {
info := ctx.GetFuncInfo(name)
if info != nil {
if info, exists := ctx.GetFuncInfo(name); exists {
v = info.Functor()
} else {
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) {
info, _ = ctx.funcStore[name]
func (ctx *SimpleFuncStore) GetFuncInfo(name string) (info ExprFunc, exists bool) {
info, exists = ctx.funcStore[name]
return
}

View File

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