Exec implements the InterpretableV2 interface method.
(frame *ExecutionFrame)
| 696 | |
| 697 | // Exec implements the InterpretableV2 interface method. |
| 698 | func (fn *evalVarArgs) Exec(frame *ExecutionFrame) ref.Val { |
| 699 | argVals := make([]ref.Val, len(fn.args)) |
| 700 | // Early return if any argument to the function is unknown or error. |
| 701 | strict := !fn.nonStrict |
| 702 | for i, arg := range fn.args { |
| 703 | argVals[i] = arg.Exec(frame) |
| 704 | if strict && types.IsUnknownOrError(argVals[i]) { |
| 705 | return argVals[i] |
| 706 | } |
| 707 | } |
| 708 | // If the implementation is bound and the argument value has the right traits required to |
| 709 | // invoke it, then call the implementation. |
| 710 | arg0 := argVals[0] |
| 711 | if fn.impl != nil && (fn.trait == 0 || (!strict && types.IsUnknownOrError(arg0)) || arg0.Type().HasTrait(fn.trait)) { |
| 712 | return types.LabelErrNode(fn.id, fn.impl(argVals...)) |
| 713 | } |
| 714 | // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the |
| 715 | // operand (arg0). |
| 716 | if arg0.Type().HasTrait(traits.ReceiverType) { |
| 717 | return types.LabelErrNode(fn.id, arg0.(traits.Receiver).Receive(fn.function, fn.overload, argVals[1:])) |
| 718 | } |
| 719 | return types.NewErrWithNodeID(fn.id, "no such overload: %s %d", fn.function, fn.id) |
| 720 | } |
| 721 | |
| 722 | // Eval implements the Interpretable interface method. |
| 723 | func (fn *evalVarArgs) Eval(ctx Activation) ref.Val { |
no test coverage detected