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

Method Exec

interpreter/interpretable.go:625–649  ·  view source on GitHub ↗

Exec implements the InterpretableV2 interface method.

(frame *ExecutionFrame)

Source from the content-addressed store, hash-verified

623
624// Exec implements the InterpretableV2 interface method.
625func (bin *evalBinary) Exec(frame *ExecutionFrame) ref.Val {
626 lVal := bin.lhs.Exec(frame)
627 rVal := bin.rhs.Exec(frame)
628 // Early return if any argument to the function is unknown or error.
629 strict := !bin.nonStrict
630 if strict {
631 if types.IsUnknownOrError(lVal) {
632 return lVal
633 }
634 if types.IsUnknownOrError(rVal) {
635 return rVal
636 }
637 }
638 // If the implementation is bound and the argument value has the right traits required to
639 // invoke it, then call the implementation.
640 if bin.impl != nil && (bin.trait == 0 || (!strict && types.IsUnknownOrError(lVal)) || lVal.Type().HasTrait(bin.trait)) {
641 return types.LabelErrNode(bin.id, bin.impl(lVal, rVal))
642 }
643 // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the
644 // operand (arg0).
645 if lVal.Type().HasTrait(traits.ReceiverType) {
646 return types.LabelErrNode(bin.id, lVal.(traits.Receiver).Receive(bin.function, bin.overload, []ref.Val{rVal}))
647 }
648 return types.NewErrWithNodeID(bin.id, "no such overload: %s", bin.function)
649}
650
651// Eval implements the Interpretable interface method.
652func (bin *evalBinary) Eval(ctx Activation) ref.Val {

Callers 1

EvalMethod · 0.95

Calls 7

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