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 -9
View File
@@ -9,6 +9,7 @@ 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/boolean"
)
//-------- NOT term
@@ -30,7 +31,7 @@ func evalNot(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
return
}
if b, ok := kern.ToBool(rightValue); ok {
if b, ok := boolean.ToBool(rightValue); ok {
v = !b
} else {
err = opTerm.ErrIncompatiblePrefixPostfixType(rightValue)
@@ -68,8 +69,8 @@ func evalAndWithoutShortcut(ctx kern.ExprContext, self *scan.Term) (v any, err e
return
}
leftBool, lok = kern.ToBool(leftValue)
rightBool, rok = kern.ToBool(rightValue)
leftBool, lok = boolean.ToBool(leftValue)
rightBool, rok = boolean.ToBool(rightValue)
if lok && rok {
v = leftBool && rightBool
@@ -90,14 +91,14 @@ func evalAndWithShortcut(ctx kern.ExprContext, self *scan.Term) (v any, err erro
return
}
if leftBool, lok := kern.ToBool(leftValue); !lok {
if leftBool, lok := boolean.ToBool(leftValue); !lok {
// err = fmt.Errorf("got %s as left operand type of 'AND' operator, it must be bool", expr.TypeName(leftValue))
// return
err = self.ErrIncompatibleType(leftValue, "left")
} else if !leftBool {
v = false
} else if rightValue, err = self.Children[1].Compute(ctx); err == nil {
if rightBool, rok := kern.ToBool(rightValue); rok {
if rightBool, rok := boolean.ToBool(rightValue); rok {
v = rightBool
} else {
err = self.ErrIncompatibleTypes(leftValue, rightValue)
@@ -136,8 +137,8 @@ func evalOrWithoutShortcut(ctx kern.ExprContext, self *scan.Term) (v any, err er
return
}
leftBool, lok = kern.ToBool(leftValue)
rightBool, rok = kern.ToBool(rightValue)
leftBool, lok = boolean.ToBool(leftValue)
rightBool, rok = boolean.ToBool(rightValue)
if lok && rok {
v = leftBool || rightBool
@@ -158,13 +159,13 @@ func evalOrWithShortcut(ctx kern.ExprContext, self *scan.Term) (v any, err error
return
}
if leftBool, lok := kern.ToBool(leftValue); !lok {
if leftBool, lok := boolean.ToBool(leftValue); !lok {
err = fmt.Errorf("got %s as left operand type of 'OR' operator, it must be bool", kern.TypeName(leftValue))
return
} else if leftBool {
v = true
} else if rightValue, err = self.Children[1].Compute(ctx); err == nil {
if rightBool, rok := kern.ToBool(rightValue); rok {
if rightBool, rok := boolean.ToBool(rightValue); rok {
v = rightBool
} else {
err = self.ErrIncompatibleTypes(leftValue, rightValue)