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

Function applyCastsInString

go/engine/expr/expression.go:93–109  ·  view source on GitHub ↗

applyCastsInString processes cast overrides like int(${}) in string expressions, applying the cast to the corresponding ref value and stripping the cast syntax from the expression.

(expression string, refs []Value)

Source from the content-addressed store, hash-verified

91 }
92 return StringVal(b.String()), nil
93}
94
95// applyCastsInString processes cast overrides like int(${}) in string
96// expressions, applying the cast to the corresponding ref value and
97// stripping the cast syntax from the expression.
98func applyCastsInString(expression string, refs []Value) (string, []Value) {
99 result := make([]Value, len(refs))
100 copy(result, refs)
101
102 for {
103 loc := castOverrideRE.FindStringSubmatchIndex(expression)
104 if loc == nil {
105 break
106 }
107 castName := expression[loc[2]:loc[3]]
108 plIdx := len(placeholderRE.FindAllStringIndex(expression[:loc[0]], -1))
109 targetType := castNameToDataType(castName)
110 result[plIdx] = result[plIdx].Cast(targetType)
111 expression = expression[:loc[0]] + "${}" + expression[loc[1]:]
112 }

Callers 1

evalStringExprFunction · 0.85

Calls 2

castNameToDataTypeFunction · 0.85
CastMethod · 0.80

Tested by

no test coverage detected