MCPcopy Create free account
hub / github.com/cel-expr/cel-go / ResolveName

Method ResolveName

interpreter/interpretable.go:2053–2084  ·  view source on GitHub ↗

ResolveName overrides the default Activation lookup to perform lazy initialization of the accumulator and specialized lookups of iteration values with consideration for whether the final result is being computed and the iteration variables should be ignored.

(name string)

Source from the content-addressed store, hash-verified

2051// and specialized lookups of iteration values with consideration for whether the final result is being
2052// computed and the iteration variables should be ignored.
2053func (f *folder) ResolveName(name string) (any, bool) {
2054 if name == f.accuVar {
2055 if !f.initialized {
2056 f.initialized = true
2057 initVal := f.accu.Exec(f.frame.parent)
2058 // Only substitute a mutable accumulator when the planner has proven that the
2059 // accumulator cannot be aliased, and when evaluation is not exhaustive since
2060 // exhaustive evaluation would apply in-place updates from untaken branches.
2061 if f.mutableAccu && !f.exhaustive {
2062 if l, isList := initVal.(traits.Lister); isList && l.Size() == types.IntZero {
2063 initVal = types.NewMutableList(f.adapter)
2064 f.mutableValue = true
2065 }
2066 if m, isMap := initVal.(traits.Mapper); isMap && m.Size() == types.IntZero {
2067 initVal = types.NewMutableMap(f.adapter, map[ref.Val]ref.Val{})
2068 f.mutableValue = true
2069 }
2070 }
2071 f.accuVal = initVal
2072 }
2073 return f.accuVal, true
2074 }
2075 if !f.computeResult {
2076 if name == f.iterVar {
2077 return f.iterVar1Val, true
2078 }
2079 if name == f.iterVar2 {
2080 return f.iterVar2Val, true
2081 }
2082 }
2083 return f.frame.parent.ResolveName(name)
2084}
2085
2086// Parent returns the activation embedded into the folder.
2087func (f *folder) Parent() Activation {

Callers

nothing calls this directly

Calls 5

NewMutableListFunction · 0.92
NewMutableMapFunction · 0.92
ExecMethod · 0.65
SizeMethod · 0.65
ResolveNameMethod · 0.65

Tested by

no test coverage detected