lang: core, funcs: Port some functions to CallableFunc API

Some modern features of our function engine and language might require
this new API, so port what we can and figure out the rest later.
This commit is contained in:
James Shubin
2025-03-16 23:23:57 -04:00
parent f313380480
commit 642c6b952f
29 changed files with 702 additions and 291 deletions

View File

@@ -150,7 +150,7 @@ func (obj *Func) Stream(ctx context.Context) error {
if obj.init.Debug {
obj.init.Logf("Calling function with: %+v", values)
}
result, err := obj.Fn.Call(ctx, values) // (Value, error)
result, err := obj.Call(ctx, values) // (Value, error)
if err != nil {
if obj.init.Debug {
obj.init.Logf("Function returned error: %+v", err)
@@ -181,3 +181,9 @@ func (obj *Func) Stream(ctx context.Context) error {
}
}
}
// Call this function with the input args and return the value if it is possible
// to do so at this time.
func (obj *Func) Call(ctx context.Context, args []types.Value) (types.Value, error) {
return obj.Fn.Call(ctx, args) // (Value, error)
}