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

Method FoldEntry

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

2017// FoldEntry will either fold comprehension v1 style macros if iterVar2 is unset, or comprehension v2 style
2018// macros if both the iterVar and iterVar2 are set to non-empty strings.
2019func (f *folder) FoldEntry(key, val any) bool {
2020 if f.listV1Fold {
2021 f.iterVar1Val = val
2022 } else {
2023 f.iterVar1Val = key
2024 f.iterVar2Val = val
2025 }
2026
2027 // Terminate evaluation if evaluation is interrupted or the condition is not true and exhaustive
2028 // eval is not enabled.
2029 cond := f.cond.Exec(f.frame)
2030 if f.interrupted {
2031 return false
2032 }
2033 if !f.exhaustive && cond != types.True {
2034 if isError(cond) {
2035 f.interrupted = true
2036 }
2037 return false
2038 }
2039
2040 // Update the accumulation value and check for eval interruption.
2041 f.accuVal = f.step.Exec(f.frame)
2042 f.initialized = true
2043 if f.interruptable && f.frame.CheckInterrupt() {
2044 f.interrupted = true
2045 return false
2046 }
2047 return true
2048}
2049
2050// ResolveName overrides the default Activation lookup to perform lazy initialization of the accumulator
2051// and specialized lookups of iteration values with consideration for whether the final result is being

Callers

nothing calls this directly

Calls 3

CheckInterruptMethod · 0.80
isErrorFunction · 0.70
ExecMethod · 0.65

Tested by

no test coverage detected