Pass ResultStack to the opcode handlers
This commit is contained in:
BlockChainDev 2019-03-18 21:13:08 +00:00
parent 351f0acdfe
commit 38ad4572c4
2 changed files with 9 additions and 2 deletions

View file

@ -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)
}

View file

@ -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,