mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
34 lines
737 B
Go
34 lines
737 B
Go
package clauses
|
|
|
|
import (
|
|
"context"
|
|
"github.com/MontFerret/ferret/pkg/runtime/collections"
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
)
|
|
|
|
type baseClause struct {
|
|
src core.SourceMap
|
|
dataSource collections.IterableExpression
|
|
}
|
|
|
|
func (clause *baseClause) Iterate(ctx context.Context, scope *core.Scope) (collections.Iterator, error) {
|
|
src, err := clause.dataSource.Iterate(ctx, scope)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return src, nil
|
|
}
|
|
|
|
func (clause *baseClause) Exec(ctx context.Context, scope *core.Scope) (core.Value, error) {
|
|
iterator, err := clause.Iterate(ctx, scope)
|
|
|
|
if err != nil {
|
|
return values.None, err
|
|
}
|
|
|
|
return collections.ToArray(iterator)
|
|
}
|