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

Method Exec

interpreter/interpretable.go:637–666  ·  view source on GitHub ↗

Exec implements the InterpretableV2 interface method.

(frame *ExecutionFrame)

Source from the content-addressed store, hash-verified

635
636// Exec implements the InterpretableV2 interface method.
637func (bin *evalBinary) Exec(frame *ExecutionFrame) ref.Val {
638 lVal := bin.lhs.Exec(frame)
639 strict := !bin.nonStrict
640 if strict && types.IsError(lVal) {
641 return lVal
642 }
643 rVal := bin.rhs.Exec(frame)
644 if strict && types.IsError(rVal) {
645 return rVal
646 }
647 if strict {
648 var unk *types.Unknown
649 unk, _ = types.MaybeMergeUnknowns(lVal, unk)
650 unk, _ = types.MaybeMergeUnknowns(rVal, unk)
651 if unk != nil {
652 return unk
653 }
654 }
655 // If the implementation is bound and the argument value has the right traits required to
656 // invoke it, then call the implementation.
657 if bin.impl != nil && (bin.trait == 0 || (!strict && types.IsUnknownOrError(lVal)) || lVal.Type().HasTrait(bin.trait)) {
658 return types.LabelErrNode(bin.id, bin.impl(lVal, rVal))
659 }
660 // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the
661 // operand (arg0).
662 if lVal.Type().HasTrait(traits.ReceiverType) {
663 return types.LabelErrNode(bin.id, lVal.(traits.Receiver).Receive(bin.function, bin.overload, []ref.Val{rVal}))
664 }
665 return types.NewErrWithNodeID(bin.id, "no such overload: %s", bin.function)
666}
667
668// Eval implements the Interpretable interface method.
669func (bin *evalBinary) Eval(ctx Activation) ref.Val {

Callers 1

EvalMethod · 0.95

Calls 9

IsErrorFunction · 0.92
MaybeMergeUnknownsFunction · 0.92
IsUnknownOrErrorFunction · 0.92
LabelErrNodeFunction · 0.92
NewErrWithNodeIDFunction · 0.92
ExecMethod · 0.65
HasTraitMethod · 0.65
TypeMethod · 0.65
ReceiveMethod · 0.65

Tested by

no test coverage detected