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

@@ -179,6 +179,12 @@ func (obj *LookupFunc) Build(typ *types.Type) (*types.Type, error) {
// programming error
return nil, err
}
if _, ok := f.(interfaces.CallableFunc); !ok {
// programming error
return nil, fmt.Errorf("not a CallableFunc")
}
bf, ok := f.(interfaces.BuildableFunc)
if !ok {
// programming error
@@ -230,3 +236,13 @@ func (obj *LookupFunc) Stream(ctx context.Context) error {
}
return obj.fn.Stream(ctx)
}
// Call returns the result of this function.
func (obj *LookupFunc) Call(ctx context.Context, args []types.Value) (types.Value, error) {
cf, ok := obj.fn.(interfaces.CallableFunc)
if !ok {
// programming error
return nil, fmt.Errorf("not a CallableFunc")
}
return cf.Call(ctx, args)
}