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

Method Exec

interpreter/interpretable.go:568–586  ·  view source on GitHub ↗

Exec implements the InterpretableV2 interface method.

(frame *ExecutionFrame)

Source from the content-addressed store, hash-verified

566
567// Exec implements the InterpretableV2 interface method.
568func (un *evalUnary) Exec(frame *ExecutionFrame) ref.Val {
569 argVal := un.arg.Exec(frame)
570 // Early return if the argument to the function is unknown or error.
571 strict := !un.nonStrict
572 if strict && types.IsUnknownOrError(argVal) {
573 return argVal
574 }
575 // If the implementation is bound and the argument value has the right traits required to
576 // invoke it, then call the implementation.
577 if un.impl != nil && (un.trait == 0 || (!strict && types.IsUnknownOrError(argVal)) || argVal.Type().HasTrait(un.trait)) {
578 return types.LabelErrNode(un.id, un.impl(argVal))
579 }
580 // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the
581 // operand (arg0).
582 if argVal.Type().HasTrait(traits.ReceiverType) {
583 return types.LabelErrNode(un.id, argVal.(traits.Receiver).Receive(un.function, un.overload, []ref.Val{}))
584 }
585 return types.NewErrWithNodeID(un.id, "no such overload: %s", un.function)
586}
587
588// Eval implements the Interpretable interface method.
589func (un *evalUnary) 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