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

Method planCallConditional

interpreter/planner.go:517–541  ·  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

515
516// planCallConditional generates a conditional / ternary (c ? t : f) Interpretable.
517func (p *planBuilder) planCallConditional(expr ast.Expr, args []InterpretableV2) (InterpretableV2, error) {
518 cond := args[0]
519 t := args[1]
520 var tAttr Attribute
521 truthyAttr, isTruthyAttr := t.(InterpretableAttribute)
522 if isTruthyAttr {
523 tAttr = truthyAttr.Attr()
524 } else {
525 tAttr = p.attrFactory.RelativeAttribute(t.ID(), t)
526 }
527
528 f := args[2]
529 var fAttr Attribute
530 falsyAttr, isFalsyAttr := f.(InterpretableAttribute)
531 if isFalsyAttr {
532 fAttr = falsyAttr.Attr()
533 } else {
534 fAttr = p.attrFactory.RelativeAttribute(f.ID(), f)
535 }
536
537 return &evalAttr{
538 adapter: p.adapter,
539 attr: p.attrFactory.ConditionalAttribute(expr.ID(), cond, tAttr, fAttr),
540 }, nil
541}
542
543// planCallIndex either extends an attribute with the argument to the index operation, or creates
544// 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