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

Method planCallConditional

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

481
482// planCallConditional generates a conditional / ternary (c ? t : f) Interpretable.
483func (p *planBuilder) planCallConditional(expr ast.Expr, args []InterpretableV2) (InterpretableV2, error) {
484 cond := args[0]
485 t := args[1]
486 var tAttr Attribute
487 truthyAttr, isTruthyAttr := t.(InterpretableAttribute)
488 if isTruthyAttr {
489 tAttr = truthyAttr.Attr()
490 } else {
491 tAttr = p.attrFactory.RelativeAttribute(t.ID(), t)
492 }
493
494 f := args[2]
495 var fAttr Attribute
496 falsyAttr, isFalsyAttr := f.(InterpretableAttribute)
497 if isFalsyAttr {
498 fAttr = falsyAttr.Attr()
499 } else {
500 fAttr = p.attrFactory.RelativeAttribute(f.ID(), f)
501 }
502
503 return &evalAttr{
504 adapter: p.adapter,
505 attr: p.attrFactory.ConditionalAttribute(expr.ID(), cond, tAttr, fAttr),
506 }, nil
507}
508
509// planCallIndex either extends an attribute with the argument to the index operation, or creates
510// 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