MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / evalCodeExpr

Function evalCodeExpr

go/engine/expr/expression.go:112–128  ·  view source on GitHub ↗

evalCodeExpr handles non-string expressions (arithmetic, comparison, boolean).

(expression string, targetType workflow.DataType, refs []Value)

Source from the content-addressed store, hash-verified

110 result[plIdx] = result[plIdx].Cast(targetType)
111 expression = expression[:loc[0]] + "${}" + expression[loc[1]:]
112 }
113 return expression, result
114}
115
116// evalCodeExpr handles non-string expressions (arithmetic, comparison, boolean).
117func evalCodeExpr(expression string, targetType workflowapi.DataType, refs []Value) (Value, error) {
118 expression, refs = applyCastsInCode(expression, refs)
119
120 if expression == "${}" && len(refs) == 1 {
121 return refs[0].Cast(targetType), nil
122 }
123
124 idx := 0
125 resolved := placeholderRE.ReplaceAllStringFunc(expression, func(_ string) string {
126 v := refs[idx]
127 idx++
128 return valueToLiteral(v)
129 })
130 resolved = strings.TrimSpace(resolved)
131

Callers 1

EvalFunction · 0.85

Calls 4

applyCastsInCodeFunction · 0.85
valueToLiteralFunction · 0.85
parseAndEvalFunction · 0.85
CastMethod · 0.80

Tested by

no test coverage detected