Exec implements the InterpretableV2 interface method.
(frame *ExecutionFrame)
| 623 | |
| 624 | // Exec implements the InterpretableV2 interface method. |
| 625 | func (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. |
| 652 | func (bin *evalBinary) Eval(ctx Activation) ref.Val { |
no test coverage detected