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

Method ResolveName

interpreter/interpretable.go:1605–1635  ·  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

1603// and specialized lookups of iteration values with consideration for whether the final result is being
1604// computed and the iteration variables should be ignored.
1605func (f *folder) ResolveName(name string) (any, bool) {
1606 if name == f.accuVar {
1607 if !f.initialized {
1608 f.initialized = true
1609 initVal := f.accu.Exec(f.frame.parent)
1610 if !f.exhaustive {
1611 if l, isList := initVal.(traits.Lister); isList && l.Size() == types.IntZero {
1612 initVal = types.NewMutableList(f.adapter)
1613 f.mutableValue = true
1614 }
1615 if m, isMap := initVal.(traits.Mapper); isMap && m.Size() == types.IntZero {
1616 initVal = types.NewMutableMap(f.adapter, map[ref.Val]ref.Val{})
1617 f.mutableValue = true
1618 }
1619 }
1620 f.accuVal = initVal
1621 }
1622 return f.accuVal, true
1623 }
1624 if !f.computeResult {
1625 if name == f.iterVar {
1626 f.iterVar1Val = f.adapter.NativeToValue(f.iterVar1Val)
1627 return f.iterVar1Val, true
1628 }
1629 if name == f.iterVar2 {
1630 f.iterVar2Val = f.adapter.NativeToValue(f.iterVar2Val)
1631 return f.iterVar2Val, true
1632 }
1633 }
1634 return f.frame.parent.ResolveName(name)
1635}
1636
1637// Parent returns the activation embedded into the folder.
1638func (f *folder) Parent() Activation {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected