Added all source files
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// operand-func.go
|
||||
package expr
|
||||
|
||||
// -------- function term
|
||||
func newFuncTerm(tk *Token, args []*term) *term {
|
||||
return &term{
|
||||
tk: *tk,
|
||||
class: classVar,
|
||||
kind: kindUnknown,
|
||||
parent: nil,
|
||||
children: args,
|
||||
position: posLeaf,
|
||||
priority: priValue,
|
||||
evalFunc: evalFunc,
|
||||
}
|
||||
}
|
||||
|
||||
// -------- eval func
|
||||
func evalFunc(ctx exprContext, self *term) (v any, err error) {
|
||||
name, _ := self.tk.Value.(string)
|
||||
params := make([]any, len(self.children))
|
||||
for i, tree := range self.children {
|
||||
var param any
|
||||
if param, err = tree.compute(ctx); err != nil {
|
||||
break
|
||||
}
|
||||
params[i] = param
|
||||
}
|
||||
if err == nil {
|
||||
v, err = ctx.Call(name, params)
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user