2019-03-15 22:36:16 +00:00
|
|
|
package vm
|
|
|
|
|
|
|
|
import "github.com/CityOfZion/neo-go/pkg/vm/stack"
|
|
|
|
|
2019-03-18 21:13:08 +00:00
|
|
|
type stackInfo func(op stack.Instruction, ctx *stack.Context, istack *stack.Invocation, rstack *stack.RandomAccess) (Vmstate, error)
|
|
|
|
|
|
|
|
var opFunc = map[stack.Instruction]stackInfo{
|
2019-03-30 15:01:06 +00:00
|
|
|
stack.NUMEQUAL: NumEqual,
|
|
|
|
stack.NUMNOTEQUAL: NumNotEqual,
|
2019-03-29 21:22:45 +00:00
|
|
|
stack.BOOLAND: BoolAnd,
|
|
|
|
stack.BOOLOR: BoolOr,
|
2019-03-29 19:35:16 +00:00
|
|
|
stack.LT: Lt,
|
2019-04-02 22:43:52 +00:00
|
|
|
stack.LTE: Lte,
|
2019-03-29 19:35:16 +00:00
|
|
|
stack.GT: Gt,
|
2019-04-02 22:43:52 +00:00
|
|
|
stack.GTE: Gte,
|
2019-03-28 22:28:20 +00:00
|
|
|
stack.SHR: Shr,
|
|
|
|
stack.SHL: Shl,
|
2019-03-26 23:15:13 +00:00
|
|
|
stack.INC: Inc,
|
|
|
|
stack.DEC: Dec,
|
2019-03-28 20:32:32 +00:00
|
|
|
stack.DIV: Div,
|
|
|
|
stack.MOD: Mod,
|
2019-03-28 19:47:47 +00:00
|
|
|
stack.NZ: Nz,
|
|
|
|
stack.MUL: Mul,
|
2019-03-28 19:26:55 +00:00
|
|
|
stack.ABS: Abs,
|
|
|
|
stack.NOT: Not,
|
2019-03-28 18:30:36 +00:00
|
|
|
stack.SIGN: Sign,
|
|
|
|
stack.NEGATE: Negate,
|
2019-03-15 23:37:54 +00:00
|
|
|
stack.ADD: Add,
|
|
|
|
stack.SUB: Sub,
|
|
|
|
stack.PUSHBYTES1: PushNBytes,
|
|
|
|
stack.PUSHBYTES75: PushNBytes,
|
2019-03-16 22:15:08 +00:00
|
|
|
stack.RET: RET,
|
|
|
|
stack.EQUAL: EQUAL,
|
|
|
|
stack.THROWIFNOT: THROWIFNOT,
|
2019-03-26 21:19:41 +00:00
|
|
|
stack.THROW: THROW,
|
2019-03-15 23:37:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
for i := int(stack.PUSHBYTES1); i <= int(stack.PUSHBYTES75); i++ {
|
|
|
|
opFunc[stack.Instruction(i)] = PushNBytes
|
|
|
|
}
|
2019-03-15 22:36:16 +00:00
|
|
|
}
|