New interface and implementation to model function parameters

This commit is contained in:
2024-05-22 20:52:44 +02:00
parent ba32e2dccf
commit 1ff5770264
19 changed files with 405 additions and 142 deletions
+6 -2
View File
@@ -31,7 +31,8 @@ func checkFunctionCall(ctx ExprContext, name string, params []any) (err error) {
err = errTooMuchParams(info.MaxArgs(), len(params))
}
if err == nil && owner != ctx {
ctx.RegisterFunc(name, info.Functor(), info.MinArgs(), info.MaxArgs())
// ctx.RegisterFunc(name, info.Functor(), info.MinArgs(), info.MaxArgs())
ctx.RegisterFuncInfo(info)
}
} else {
err = fmt.Errorf("unknown function %s()", name)
@@ -85,7 +86,10 @@ func (functor *funcDefFunctor) Invoke(ctx ExprContext, name string, args []any)
if i < len(args) {
arg := args[i]
if functor, ok := arg.(Functor); ok {
ctx.RegisterFunc(p, functor, 0, -1)
// ctx.RegisterFunc(p, functor, 0, -1)
ctx.RegisterFunc2(p, functor, typeAny, []ExprFuncParam{
newFuncParam(paramValue),
})
} else {
ctx.UnsafeSetVar(p, arg)
}