From d354102c6adfde6fbba18b4015f8b9aa7e67c6c9 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Fri, 26 Apr 2024 04:36:03 +0200 Subject: [PATCH] adapted to the new GetFuncInfo() specification --- operand-func.go | 6 ++---- operand-var.go | 3 +-- simple-func-store.go | 4 ++-- simple-var-store.go | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/operand-func.go b/operand-func.go index cb489de..5391579 100644 --- a/operand-func.go +++ b/operand-func.go @@ -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) } } diff --git a/operand-var.go b/operand-var.go index 6b0f96c..04fd4d2 100644 --- a/operand-var.go +++ b/operand-var.go @@ -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) diff --git a/simple-func-store.go b/simple-func-store.go index 302e34e..4639341 100644 --- a/simple-func-store.go +++ b/simple-func-store.go @@ -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 } diff --git a/simple-var-store.go b/simple-var-store.go index 416eb17..6ac8012 100644 --- a/simple-var-store.go +++ b/simple-var-store.go @@ -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 }