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

Method FoldEntry

interpreter/interpretable.go:1537–1558  ·  view source on GitHub ↗

FoldEntry will either fold comprehension v1 style macros if iterVar2 is unset, or comprehension v2 style macros if both the iterVar and iterVar2 are set to non-empty strings.

(key, val any)

Source from the content-addressed store, hash-verified

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.
1537func (f *folder) FoldEntry(key, val any) bool {
1538 // Default to referencing both values.
1539 f.iterVar1Val = key
1540 f.iterVar2Val = val
1541
1542 // Terminate evaluation if evaluation is interrupted or the condition is not true and exhaustive
1543 // eval is not enabled.
1544 cond := f.cond.Exec(f.frame)
1545 condBool, ok := cond.(types.Bool)
1546 if f.interrupted || (!f.exhaustive && ok && condBool != types.True) {
1547 return false
1548 }
1549
1550 // Update the accumulation value and check for eval interuption.
1551 f.accuVal = f.step.Exec(f.frame)
1552 f.initialized = true
1553 if f.interruptable && f.frame.CheckInterrupt() {
1554 f.interrupted = true
1555 return false
1556 }
1557 return true
1558}
1559
1560// ResolveName overrides the default Activation lookup to perform lazy initialization of the accumulator
1561// and specialized lookups of iteration values with consideration for whether the final result is being

Callers

nothing calls this directly

Calls 2

CheckInterruptMethod · 0.80
ExecMethod · 0.65

Tested by

no test coverage detected