made some interfaces exportable and fixed/enhaaced some selector operator versions

This commit is contained in:
2024-04-08 23:17:56 +02:00
parent aa195b9a68
commit 9ac88bf446
29 changed files with 99 additions and 98 deletions
+6 -6
View File
@@ -23,7 +23,7 @@ func newFuncCallTerm(tk *Token, args []*term) *term {
}
// -------- eval func call
func evalFuncCall(parentCtx exprContext, self *term) (v any, err error) {
func evalFuncCall(parentCtx ExprContext, self *term) (v any, err error) {
ctx := parentCtx.Clone()
name, _ := self.tk.Value.(string)
params := make([]any, len(self.children))
@@ -53,14 +53,14 @@ func evalFuncCall(parentCtx exprContext, self *term) (v any, err error) {
return
}
func exportVar(ctx exprContext, name string, value any) {
func exportVar(ctx ExprContext, name string, value any) {
if name[0] == '@' {
name = name[1:]
}
ctx.SetVar(name, value)
}
func exportFunc(ctx exprContext, name string, info exprFunc) {
func exportFunc(ctx ExprContext, name string, info ExprFunc) {
if name[0] == '@' {
name = name[1:]
}
@@ -88,7 +88,7 @@ type funcDefFunctor struct {
expr Expr
}
func (functor *funcDefFunctor) Invoke(ctx exprContext, name string, args []any) (result any, err error) {
func (functor *funcDefFunctor) Invoke(ctx ExprContext, name string, args []any) (result any, err error) {
for i, p := range functor.params {
if i < len(args) {
ctx.SetVar(p, args[i])
@@ -96,11 +96,11 @@ func (functor *funcDefFunctor) Invoke(ctx exprContext, name string, args []any)
ctx.SetVar(p, nil)
}
}
result, err = functor.expr.Eval(ctx, false)
result, err = functor.expr.eval(ctx, false)
return
}
func evalFuncDef(ctx exprContext, self *term) (v any, err error) {
func evalFuncDef(ctx ExprContext, self *term) (v any, err error) {
bodySpec := self.value()
if expr, ok := bodySpec.(*ast); ok {
paramList := make([]string, 0, len(self.children))