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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user