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

Method foldIterable

interpreter/interpretable.go:1513–1533  ·  view source on GitHub ↗
(iterable traits.Iterable)

Source from the content-addressed store, hash-verified

1511}
1512
1513func (f *folder) foldIterable(iterable traits.Iterable) ref.Val {
1514 it := iterable.Iterator()
1515 for it.HasNext() == types.True {
1516 f.iterVar1Val = it.Next()
1517
1518 cond := f.cond.Exec(f.frame)
1519 condBool, ok := cond.(types.Bool)
1520 if f.interrupted || (!f.exhaustive && ok && condBool != types.True) {
1521 return f.evalResult()
1522 }
1523
1524 // Update the accumulation value and check for eval interuption.
1525 f.accuVal = f.step.Exec(f.frame)
1526 f.initialized = true
1527 if f.interruptable && f.frame.CheckInterrupt() {
1528 f.interrupted = true
1529 return f.evalResult()
1530 }
1531 }
1532 return f.evalResult()
1533}
1534
1535// FoldEntry will either fold comprehension v1 style macros if iterVar2 is unset, or comprehension v2 style
1536// macros if both the iterVar and iterVar2 are set to non-empty strings.

Callers 1

ExecMethod · 0.80

Calls 6

evalResultMethod · 0.95
CheckInterruptMethod · 0.80
IteratorMethod · 0.65
HasNextMethod · 0.65
NextMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected