diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 604348baf..1f9fa66df 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -8,6 +8,11 @@ import ( // VM represents an instance of a Neo Virtual Machine type VM struct { + // ResultStack contains the results of + // the last evaluation stack before the program terminated + ResultStack stack.RandomAccess + // InvocationStack contains all of the contexts + // loaded into the vm InvocationStack stack.Invocation state Vmstate } @@ -63,5 +68,5 @@ func (v *VM) executeOp(op stack.Instruction, ctx *stack.Context) (Vmstate, error if !ok { return FAULT, fmt.Errorf("unknown opcode entered %v", op) } - return handleOp(op, ctx, &v.InvocationStack) + return handleOp(op, ctx, &v.InvocationStack, &v.ResultStack) } diff --git a/pkg/vm/vm_ops.go b/pkg/vm/vm_ops.go index bf9291933..39b796389 100644 --- a/pkg/vm/vm_ops.go +++ b/pkg/vm/vm_ops.go @@ -2,7 +2,9 @@ package vm import "github.com/CityOfZion/neo-go/pkg/vm/stack" -var opFunc = map[stack.Instruction]func(op stack.Instruction, ctx *stack.Context, istack *stack.Invocation) (Vmstate, error){ +type stackInfo func(op stack.Instruction, ctx *stack.Context, istack *stack.Invocation, rstack *stack.RandomAccess) (Vmstate, error) + +var opFunc = map[stack.Instruction]stackInfo{ stack.ADD: Add, stack.SUB: Sub, stack.PUSHBYTES1: PushNBytes,