new iter-iter iterator and kern.func-info module

This commit is contained in:
2026-05-05 20:38:30 +02:00
parent 7f34ccf955
commit acd4f8487d
30 changed files with 527 additions and 485 deletions
+20 -2
View File
@@ -5,10 +5,13 @@
package expr
import (
"fmt"
"slices"
"git.portale-stac.it/go-pkg/expr/kern"
)
func NewIterator(value any) (it kern.Iterator, err error) {
func NewIterator(ctx kern.ExprContext, value any, args map[string]any) (it kern.Iterator, err error) {
if value == nil {
return NewArrayIterator([]any{}), nil
}
@@ -21,9 +24,24 @@ func NewIterator(value any) (it kern.Iterator, err error) {
case []any:
it = NewArrayIterator(v)
case kern.Iterator:
it = v
// it = v
var op kern.Functor
if len(args) >= 1 {
if opArg, ok := args["op"]; ok {
if op, ok = opArg.(kern.Functor); !ok {
err = fmt.Errorf("the 'op' argument must be a kern.Functor, got %T", opArg)
}
}
}
if err == nil {
it, err = NewIterIter(v, ctx, op, args)
}
default:
it = NewArrayIterator([]any{value})
}
return
}
func HasStandardOperation(name string) bool {
return slices.Contains([]string{kern.NextName, kern.ResetName, kern.IndexName, kern.CountName, kern.CurrentName, kern.CleanName}, name)
}