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

Method Exec

interpreter/interpretable.go:698–720  ·  view source on GitHub ↗

Exec implements the InterpretableV2 interface method.

(frame *ExecutionFrame)

Source from the content-addressed store, hash-verified

696
697// Exec implements the InterpretableV2 interface method.
698func (fn *evalVarArgs) Exec(frame *ExecutionFrame) ref.Val {
699 argVals := make([]ref.Val, len(fn.args))
700 // Early return if any argument to the function is unknown or error.
701 strict := !fn.nonStrict
702 for i, arg := range fn.args {
703 argVals[i] = arg.Exec(frame)
704 if strict && types.IsUnknownOrError(argVals[i]) {
705 return argVals[i]
706 }
707 }
708 // If the implementation is bound and the argument value has the right traits required to
709 // invoke it, then call the implementation.
710 arg0 := argVals[0]
711 if fn.impl != nil && (fn.trait == 0 || (!strict && types.IsUnknownOrError(arg0)) || arg0.Type().HasTrait(fn.trait)) {
712 return types.LabelErrNode(fn.id, fn.impl(argVals...))
713 }
714 // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the
715 // operand (arg0).
716 if arg0.Type().HasTrait(traits.ReceiverType) {
717 return types.LabelErrNode(fn.id, arg0.(traits.Receiver).Receive(fn.function, fn.overload, argVals[1:]))
718 }
719 return types.NewErrWithNodeID(fn.id, "no such overload: %s %d", fn.function, fn.id)
720}
721
722// Eval implements the Interpretable interface method.
723func (fn *evalVarArgs) 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