Exec implements the InterpretableV2 interface method.
(frame *ExecutionFrame)
| 566 | |
| 567 | // Exec implements the InterpretableV2 interface method. |
| 568 | func (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. |
| 589 | func (un *evalUnary) Eval(ctx Activation) ref.Val { |
no test coverage detected