Exec implements the InterpretableV2 interface method.
(frame *ExecutionFrame)
| 578 | |
| 579 | // Exec implements the InterpretableV2 interface method. |
| 580 | func (un *evalUnary) Exec(frame *ExecutionFrame) ref.Val { |
| 581 | argVal := un.arg.Exec(frame) |
| 582 | // Early return if the argument to the function is unknown or error. |
| 583 | strict := !un.nonStrict |
| 584 | if strict && types.IsUnknownOrError(argVal) { |
| 585 | return argVal |
| 586 | } |
| 587 | // If the implementation is bound and the argument value has the right traits required to |
| 588 | // invoke it, then call the implementation. |
| 589 | if un.impl != nil && (un.trait == 0 || (!strict && types.IsUnknownOrError(argVal)) || argVal.Type().HasTrait(un.trait)) { |
| 590 | return types.LabelErrNode(un.id, un.impl(argVal)) |
| 591 | } |
| 592 | // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the |
| 593 | // operand (arg0). |
| 594 | if argVal.Type().HasTrait(traits.ReceiverType) { |
| 595 | return types.LabelErrNode(un.id, argVal.(traits.Receiver).Receive(un.function, un.overload, []ref.Val{})) |
| 596 | } |
| 597 | return types.NewErrWithNodeID(un.id, "no such overload: %s", un.function) |
| 598 | } |
| 599 | |
| 600 | // Eval implements the Interpretable interface method. |
| 601 | func (un *evalUnary) Eval(ctx Activation) ref.Val { |
no test coverage detected