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

Function evaluateExpr

cel/folding.go:169–191  ·  view source on GitHub ↗
(ctx *OptimizerContext, a *ast.AST, navigableExpr ast.NavigableExpr, activation Activation)

Source from the content-addressed store, hash-verified

167}
168
169func evaluateExpr(ctx *OptimizerContext, a *ast.AST, navigableExpr ast.NavigableExpr, activation Activation) (ref.Val, error) {
170 partialActivation, err := ctx.PartialVars(activation)
171 if err != nil {
172 return nil, err
173 }
174 subAST := &Ast{
175 impl: ast.NewCheckedAST(ast.NewAST(navigableExpr, a.SourceInfo()), a.TypeMap(), a.ReferenceMap()),
176 }
177 prg, err := ctx.Program(subAST)
178 if err != nil {
179 return nil, errCannotFold
180 }
181 // Folding will not attempt to call async functions,
182 // but the presence of such functions requires the use of `ConcurrentEval` in order to
183 // avoid an early return error which blocks async functions from running in `Eval` and
184 // `ContextEval` call paths.
185 resCh := prg.ConcurrentEval(context.Background(), partialActivation)
186 res := <-resCh
187 if res.Err != nil || types.IsUnknown(res.Val) {
188 return nil, errCannotFold
189 }
190 return res.Val, nil
191}
192
193func isLateBoundFunctionCall(ctx *OptimizerContext, expr ast.Expr) bool {
194 call := expr.AsCall()

Callers 1

tryFoldMethod · 0.85

Calls 9

NewCheckedASTFunction · 0.92
NewASTFunction · 0.92
IsUnknownFunction · 0.92
PartialVarsMethod · 0.80
TypeMapMethod · 0.80
ReferenceMapMethod · 0.80
ProgramMethod · 0.80
ConcurrentEvalMethod · 0.65
SourceInfoMethod · 0.45

Tested by

no test coverage detected