[VM]
Pass ResultStack to the opcode handlers
This commit is contained in:
parent
351f0acdfe
commit
38ad4572c4
2 changed files with 9 additions and 2 deletions
|
@ -8,6 +8,11 @@ import (
|
||||||
|
|
||||||
// VM represents an instance of a Neo Virtual Machine
|
// VM represents an instance of a Neo Virtual Machine
|
||||||
type VM struct {
|
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
|
InvocationStack stack.Invocation
|
||||||
state Vmstate
|
state Vmstate
|
||||||
}
|
}
|
||||||
|
@ -63,5 +68,5 @@ func (v *VM) executeOp(op stack.Instruction, ctx *stack.Context) (Vmstate, error
|
||||||
if !ok {
|
if !ok {
|
||||||
return FAULT, fmt.Errorf("unknown opcode entered %v", op)
|
return FAULT, fmt.Errorf("unknown opcode entered %v", op)
|
||||||
}
|
}
|
||||||
return handleOp(op, ctx, &v.InvocationStack)
|
return handleOp(op, ctx, &v.InvocationStack, &v.ResultStack)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package vm
|
||||||
|
|
||||||
import "github.com/CityOfZion/neo-go/pkg/vm/stack"
|
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.ADD: Add,
|
||||||
stack.SUB: Sub,
|
stack.SUB: Sub,
|
||||||
stack.PUSHBYTES1: PushNBytes,
|
stack.PUSHBYTES1: PushNBytes,
|
||||||
|
|
Loading…
Reference in a new issue