aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/opcodes.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/vm/opcodes.go')
-rw-r--r--core/vm/opcodes.go26
1 files changed, 23 insertions, 3 deletions
diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go
index 986c35ef8..dc4139092 100644
--- a/core/vm/opcodes.go
+++ b/core/vm/opcodes.go
@@ -23,6 +23,18 @@ import (
// OpCode is an EVM opcode
type OpCode byte
+func (op OpCode) IsPush() bool {
+ switch op {
+ case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32:
+ return true
+ }
+ return false
+}
+
+func (op OpCode) IsStaticJump() bool {
+ return op == JUMP
+}
+
const (
// 0x0 range - arithmetic ops
STOP OpCode = iota
@@ -175,6 +187,13 @@ const (
LOG4
)
+// unofficial opcodes used for parsing
+const (
+ PUSH OpCode = 0xb0 + iota
+ DUP
+ SWAP
+)
+
const (
// 0xf0 range - closures
CREATE OpCode = 0xf0 + iota
@@ -182,7 +201,6 @@ const (
CALLCODE
RETURN
- // 0x70 range - other
SUICIDE = 0xff
)
@@ -335,9 +353,11 @@ var opCodeToString = map[OpCode]string{
CALL: "CALL",
RETURN: "RETURN",
CALLCODE: "CALLCODE",
+ SUICIDE: "SUICIDE",
- // 0x70 range - other
- SUICIDE: "SUICIDE",
+ PUSH: "PUSH",
+ DUP: "DUP",
+ SWAP: "SWAP",
}
func (o OpCode) String() string {