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
+11 -7
View File
@@ -4,6 +4,10 @@
// operator-context-value.go
package expr
import (
"git.portale-stac.it/go-pkg/expr/kern"
)
//-------- context term
func newContextTerm(tk *Token) (inst *term) {
@@ -16,14 +20,14 @@ func newContextTerm(tk *Token) (inst *term) {
}
}
func evalContextValue(ctx ExprContext, opTerm *term) (v any, err error) {
func evalContextValue(ctx kern.ExprContext, opTerm *term) (v any, err error) {
var childValue any
var sourceCtx ExprContext
var sourceCtx kern.ExprContext
if len(opTerm.children) == 0 {
sourceCtx = ctx
} else if opTerm.children[0].symbol() == SymVariable && opTerm.children[0].source() == "global" {
sourceCtx = globalCtx
} else if opTerm.children[0].symbol() == SymVariable && opTerm.children[0].Source() == "global" {
sourceCtx = ctx.GetGlobal()
} else if childValue, err = opTerm.evalPrefix(ctx); err == nil {
if dc, ok := childValue.(*dataCursor); ok {
sourceCtx = dc.ctx
@@ -31,9 +35,9 @@ func evalContextValue(ctx ExprContext, opTerm *term) (v any, err error) {
}
if sourceCtx != nil {
if formatter, ok := sourceCtx.(DictFormat); ok {
if formatter, ok := sourceCtx.(kern.DictFormat); ok {
v = formatter.ToDict()
} else if formatter, ok := sourceCtx.(Formatter); ok {
} else if formatter, ok := sourceCtx.(kern.Formatter); ok {
v = formatter.ToString(0)
} else {
// keys := sourceCtx.EnumVars(func(name string) bool { return name[0] != '_' })
@@ -49,7 +53,7 @@ func evalContextValue(ctx ExprContext, opTerm *term) (v any, err error) {
v = d
}
} else {
err = opTerm.errIncompatibleType(childValue)
err = opTerm.errIncompatiblePrefixPostfixType(childValue)
}
return
}