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

Function applyCastsInCode

go/engine/expr/expression.go:131–147  ·  view source on GitHub ↗

applyCastsInCode processes cast functions in non-string expressions.

(expression string, refs []Value)

Source from the content-addressed store, hash-verified

129 })
130 resolved = strings.TrimSpace(resolved)
131
132 return parseAndEval(resolved, targetType)
133}
134
135// applyCastsInCode processes cast functions in non-string expressions.
136func applyCastsInCode(expression string, refs []Value) (string, []Value) {
137 result := make([]Value, len(refs))
138 copy(result, refs)
139
140 for {
141 loc := castOverrideRE.FindStringSubmatchIndex(expression)
142 if loc == nil {
143 break
144 }
145 castName := expression[loc[2]:loc[3]]
146 plIdx := len(placeholderRE.FindAllStringIndex(expression[:loc[0]], -1))
147 targetType := castNameToDataType(castName)
148 result[plIdx] = result[plIdx].Cast(targetType)
149 expression = expression[:loc[0]] + "${}" + expression[loc[1]:]
150 }

Callers 1

evalCodeExprFunction · 0.85

Calls 2

castNameToDataTypeFunction · 0.85
CastMethod · 0.80

Tested by

no test coverage detected