Exec implements the InterpretableV2 interface method.
(frame *ExecutionFrame)
| 635 | |
| 636 | // Exec implements the InterpretableV2 interface method. |
| 637 | func (bin *evalBinary) Exec(frame *ExecutionFrame) ref.Val { |
| 638 | lVal := bin.lhs.Exec(frame) |
| 639 | strict := !bin.nonStrict |
| 640 | if strict && types.IsError(lVal) { |
| 641 | return lVal |
| 642 | } |
| 643 | rVal := bin.rhs.Exec(frame) |
| 644 | if strict && types.IsError(rVal) { |
| 645 | return rVal |
| 646 | } |
| 647 | if strict { |
| 648 | var unk *types.Unknown |
| 649 | unk, _ = types.MaybeMergeUnknowns(lVal, unk) |
| 650 | unk, _ = types.MaybeMergeUnknowns(rVal, unk) |
| 651 | if unk != nil { |
| 652 | return unk |
| 653 | } |
| 654 | } |
| 655 | // If the implementation is bound and the argument value has the right traits required to |
| 656 | // invoke it, then call the implementation. |
| 657 | if bin.impl != nil && (bin.trait == 0 || (!strict && types.IsUnknownOrError(lVal)) || lVal.Type().HasTrait(bin.trait)) { |
| 658 | return types.LabelErrNode(bin.id, bin.impl(lVal, rVal)) |
| 659 | } |
| 660 | // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the |
| 661 | // operand (arg0). |
| 662 | if lVal.Type().HasTrait(traits.ReceiverType) { |
| 663 | return types.LabelErrNode(bin.id, lVal.(traits.Receiver).Receive(bin.function, bin.overload, []ref.Val{rVal})) |
| 664 | } |
| 665 | return types.NewErrWithNodeID(bin.id, "no such overload: %s", bin.function) |
| 666 | } |
| 667 | |
| 668 | // Eval implements the Interpretable interface method. |
| 669 | func (bin *evalBinary) Eval(ctx Activation) ref.Val { |
no test coverage detected