refactored data-types to reduce plugin sizes

This commit is contained in:
2026-06-08 07:02:56 +02:00
parent fec7cc546c
commit b6da9bcad4
90 changed files with 1039 additions and 803 deletions
+10 -12
View File
@@ -7,6 +7,10 @@ package expr
import (
"git.portale-stac.it/go-pkg/expr/kern"
"git.portale-stac.it/go-pkg/expr/scan"
"git.portale-stac.it/go-pkg/expr/types/array"
"git.portale-stac.it/go-pkg/expr/types/dict"
"git.portale-stac.it/go-pkg/expr/types/list"
"git.portale-stac.it/go-pkg/expr/types/str"
)
//-------- length term
@@ -28,25 +32,19 @@ func evalLength(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
return
}
if kern.IsList(childValue) {
ls, _ := childValue.(*kern.ListType)
if array.IsList(childValue) {
ls, _ := childValue.(*array.ListType)
v = int64(len(*ls))
} else if kern.IsString(childValue) {
} else if str.IsString(childValue) {
s, _ := childValue.(string)
v = int64(len(s))
} else if kern.IsDict(childValue) {
m, _ := childValue.(*kern.DictType)
} else if dict.IsDict(childValue) {
m, _ := childValue.(*dict.DictType)
v = int64(len(*m))
} else if lls, ok := childValue.(*kern.LinkedList); ok {
} else if lls, ok := childValue.(*list.LinkedList); ok {
v = int64(lls.Len())
} 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)
// v, _ = ToGoInt(count, "")
// } else {
// v = int64(it.Index() + 1)
// }
} else {
err = opTerm.ErrIncompatiblePrefixPostfixType(childValue)
}