moved a subset of source file to the kern package

This commit is contained in:
2026-04-27 19:43:37 +02:00
parent f100adead3
commit 4d910dd069
107 changed files with 2080 additions and 1380 deletions
+12 -8
View File
@@ -4,6 +4,10 @@
// operator-length.go
package expr
import (
"git.portale-stac.it/go-pkg/expr/kern"
)
//-------- length term
func newLengthTerm(tk *Token) (inst *term) {
@@ -16,23 +20,23 @@ func newLengthTerm(tk *Token) (inst *term) {
}
}
func evalLength(ctx ExprContext, opTerm *term) (v any, err error) {
func evalLength(ctx kern.ExprContext, opTerm *term) (v any, err error) {
var childValue any
if childValue, err = opTerm.evalPrefix(ctx); err != nil {
return
}
if IsList(childValue) {
ls, _ := childValue.(*ListType)
if kern.IsList(childValue) {
ls, _ := childValue.(*kern.ListType)
v = int64(len(*ls))
} else if IsString(childValue) {
} else if kern.IsString(childValue) {
s, _ := childValue.(string)
v = int64(len(s))
} else if IsDict(childValue) {
m, _ := childValue.(*DictType)
} else if kern.IsDict(childValue) {
m, _ := childValue.(*kern.DictType)
v = int64(len(*m))
} else if it, ok := childValue.(Iterator); ok {
} else if it, ok := childValue.(kern.Iterator); ok {
v = int64(it.Count())
// if extIt, ok := childValue.(ExtIterator); ok && extIt.HasOperation(CountName) {
// count, _ := extIt.CallOperation(CountName, nil)
@@ -41,7 +45,7 @@ func evalLength(ctx ExprContext, opTerm *term) (v any, err error) {
// v = int64(it.Index() + 1)
// }
} else {
err = opTerm.errIncompatibleType(childValue)
err = opTerm.errIncompatiblePrefixPostfixType(childValue)
}
return
}