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

Method planCallConditional

interpreter/planner.go:464–488  ·  view source on GitHub ↗

planCallConditional generates a conditional / ternary (c ? t : f) Interpretable.

(expr ast.Expr, args []InterpretableV2)

Source from the content-addressed store, hash-verified

462
463// planCallConditional generates a conditional / ternary (c ? t : f) Interpretable.
464func (p *planBuilder) planCallConditional(expr ast.Expr, args []InterpretableV2) (InterpretableV2, error) {
465 cond := args[0]
466 t := args[1]
467 var tAttr Attribute
468 truthyAttr, isTruthyAttr := t.(InterpretableAttribute)
469 if isTruthyAttr {
470 tAttr = truthyAttr.Attr()
471 } else {
472 tAttr = p.attrFactory.RelativeAttribute(t.ID(), t)
473 }
474
475 f := args[2]
476 var fAttr Attribute
477 falsyAttr, isFalsyAttr := f.(InterpretableAttribute)
478 if isFalsyAttr {
479 fAttr = falsyAttr.Attr()
480 } else {
481 fAttr = p.attrFactory.RelativeAttribute(f.ID(), f)
482 }
483
484 return &evalAttr{
485 adapter: p.adapter,
486 attr: p.attrFactory.ConditionalAttribute(expr.ID(), cond, tAttr, fAttr),
487 }, nil
488}
489
490// planCallIndex either extends an attribute with the argument to the index operation, or creates
491// a relative attribute based on the return of a function call or operation.

Callers 1

planCallMethod · 0.95

Calls 4

AttrMethod · 0.65
RelativeAttributeMethod · 0.65
IDMethod · 0.65
ConditionalAttributeMethod · 0.65

Tested by

no test coverage detected