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)
| 1561 | // and specialized lookups of iteration values with consideration for whether the final result is being |
| 1562 | // computed and the iteration variables should be ignored. |
| 1563 | func (f *folder) ResolveName(name string) (any, bool) { |
| 1564 | if name == f.accuVar { |
| 1565 | if !f.initialized { |
| 1566 | f.initialized = true |
| 1567 | initVal := f.accu.Exec(f.frame.parent) |
| 1568 | if !f.exhaustive { |
| 1569 | if l, isList := initVal.(traits.Lister); isList && l.Size() == types.IntZero { |
| 1570 | initVal = types.NewMutableList(f.adapter) |
| 1571 | f.mutableValue = true |
| 1572 | } |
| 1573 | if m, isMap := initVal.(traits.Mapper); isMap && m.Size() == types.IntZero { |
| 1574 | initVal = types.NewMutableMap(f.adapter, map[ref.Val]ref.Val{}) |
| 1575 | f.mutableValue = true |
| 1576 | } |
| 1577 | } |
| 1578 | f.accuVal = initVal |
| 1579 | } |
| 1580 | return f.accuVal, true |
| 1581 | } |
| 1582 | if !f.computeResult { |
| 1583 | if name == f.iterVar { |
| 1584 | f.iterVar1Val = f.adapter.NativeToValue(f.iterVar1Val) |
| 1585 | return f.iterVar1Val, true |
| 1586 | } |
| 1587 | if name == f.iterVar2 { |
| 1588 | f.iterVar2Val = f.adapter.NativeToValue(f.iterVar2Val) |
| 1589 | return f.iterVar2Val, true |
| 1590 | } |
| 1591 | } |
| 1592 | return f.frame.parent.ResolveName(name) |
| 1593 | } |
| 1594 | |
| 1595 | // Parent returns the activation embedded into the folder. |
| 1596 | func (f *folder) Parent() Activation { |
nothing calls this directly
no test coverage detected