forked from cerc-io/plugeth
Added stack and opcodes to a separate file
This commit is contained in:
parent
8c4eca2490
commit
fd7e79f4e3
114
stack.go
114
stack.go
@ -6,59 +6,61 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpCode byte
|
type OpCode int
|
||||||
|
|
||||||
// Op codes
|
// Op codes
|
||||||
const (
|
const (
|
||||||
oSTOP OpCode = 0x00
|
oSTOP OpCode = iota
|
||||||
oADD OpCode = 0x01
|
oADD
|
||||||
oMUL OpCode = 0x02
|
oMUL
|
||||||
oSUB OpCode = 0x03
|
oSUB
|
||||||
oDIV OpCode = 0x04
|
oDIV
|
||||||
oSDIV OpCode = 0x05
|
oSDIV
|
||||||
oMOD OpCode = 0x06
|
oMOD
|
||||||
oSMOD OpCode = 0x07
|
oSMOD
|
||||||
oEXP OpCode = 0x08
|
oEXP
|
||||||
oNEG OpCode = 0x09
|
oNEG
|
||||||
oLT OpCode = 0x0a
|
oLT
|
||||||
oLE OpCode = 0x0b
|
oLE
|
||||||
oGT OpCode = 0x0c
|
oGT
|
||||||
oGE OpCode = 0x0d
|
oGE
|
||||||
oEQ OpCode = 0x0e
|
oEQ
|
||||||
oNOT OpCode = 0x0f
|
oNOT
|
||||||
oMYADDRESS OpCode = 0x10
|
oMYADDRESS
|
||||||
oTXSENDER OpCode = 0x11
|
oTXSENDER
|
||||||
oTXVALUE OpCode = 0x12
|
oTXVALUE
|
||||||
oTXFEE OpCode = 0x13
|
oTXFEE
|
||||||
oTXDATAN OpCode = 0x14
|
oTXDATAN
|
||||||
oTXDATA OpCode = 0x15
|
oTXDATA
|
||||||
oBLK_PREVHASH OpCode = 0x16
|
oBLK_PREVHASH
|
||||||
oBLK_COINBASE OpCode = 0x17
|
oBLK_COINBASE
|
||||||
oBLK_TIMESTAMP OpCode = 0x18
|
oBLK_TIMESTAMP
|
||||||
oBLK_NUMBER OpCode = 0x19
|
oBLK_NUMBER
|
||||||
oBLK_DIFFICULTY OpCode = 0x1a
|
oBLK_DIFFICULTY
|
||||||
oSHA256 OpCode = 0x20
|
oBASEFEE
|
||||||
oRIPEMD160 OpCode = 0x21
|
oSHA256 OpCode = 32
|
||||||
oECMUL OpCode = 0x22
|
oRIPEMD160 OpCode = 33
|
||||||
oECADD OpCode = 0x23
|
oECMUL OpCode = 34
|
||||||
oECSIGN OpCode = 0x24
|
oECADD OpCode = 35
|
||||||
oECRECOVER OpCode = 0x25
|
oECSIGN OpCode = 36
|
||||||
oECVALID OpCode = 0x26
|
oECRECOVER OpCode = 37
|
||||||
oPUSH OpCode = 0x30
|
oECVALID OpCode = 38
|
||||||
oPOP OpCode = 0x31
|
oSHA3 OpCode = 39
|
||||||
oDUP OpCode = 0x32
|
oPUSH OpCode = 48
|
||||||
oDUPN OpCode = 0x33
|
oPOP OpCode = 49
|
||||||
oSWAP OpCode = 0x34
|
oDUP OpCode = 50
|
||||||
oSWAPN OpCode = 0x35
|
oSWAP OpCode = 51
|
||||||
oLOAD OpCode = 0x36
|
oMLOAD OpCode = 52
|
||||||
oSTORE OpCode = 0x37
|
oMSTORE OpCode = 53
|
||||||
oJMP OpCode = 0x40
|
oSLOAD OpCode = 54
|
||||||
oJMPI OpCode = 0x41
|
oSSTORE OpCode = 55
|
||||||
oIND OpCode = 0x42
|
oJMP OpCode = 56
|
||||||
oEXTRO OpCode = 0x50
|
oJMPI OpCode = 57
|
||||||
oBALANCE OpCode = 0x51
|
oIND OpCode = 58
|
||||||
oMKTX OpCode = 0x60
|
oEXTRO OpCode = 59
|
||||||
oSUICIDE OpCode = 0xff
|
oBALANCE OpCode = 60
|
||||||
|
oMKTX OpCode = 61
|
||||||
|
oSUICIDE OpCode = 62
|
||||||
)
|
)
|
||||||
|
|
||||||
// Since the opcodes aren't all in order we can't use a regular slice
|
// Since the opcodes aren't all in order we can't use a regular slice
|
||||||
@ -89,7 +91,8 @@ var opCodeToString = map[OpCode]string{
|
|||||||
oBLK_COINBASE: "BLK_COINBASE",
|
oBLK_COINBASE: "BLK_COINBASE",
|
||||||
oBLK_TIMESTAMP: "BLK_TIMESTAMP",
|
oBLK_TIMESTAMP: "BLK_TIMESTAMP",
|
||||||
oBLK_NUMBER: "BLK_NUMBER",
|
oBLK_NUMBER: "BLK_NUMBER",
|
||||||
oBLK_DIFFICULTY: "BLK_DIFFIFULTY",
|
oBLK_DIFFICULTY: "BLK_DIFFICULTY",
|
||||||
|
oBASEFEE: "BASEFEE",
|
||||||
oSHA256: "SHA256",
|
oSHA256: "SHA256",
|
||||||
oRIPEMD160: "RIPEMD160",
|
oRIPEMD160: "RIPEMD160",
|
||||||
oECMUL: "ECMUL",
|
oECMUL: "ECMUL",
|
||||||
@ -97,14 +100,15 @@ var opCodeToString = map[OpCode]string{
|
|||||||
oECSIGN: "ECSIGN",
|
oECSIGN: "ECSIGN",
|
||||||
oECRECOVER: "ECRECOVER",
|
oECRECOVER: "ECRECOVER",
|
||||||
oECVALID: "ECVALID",
|
oECVALID: "ECVALID",
|
||||||
|
oSHA3: "SHA3",
|
||||||
oPUSH: "PUSH",
|
oPUSH: "PUSH",
|
||||||
oPOP: "POP",
|
oPOP: "POP",
|
||||||
oDUP: "DUP",
|
oDUP: "DUP",
|
||||||
oDUPN: "DUPN",
|
|
||||||
oSWAP: "SWAP",
|
oSWAP: "SWAP",
|
||||||
oSWAPN: "SWAPN",
|
oMLOAD: "MLOAD",
|
||||||
oLOAD: "LOAD",
|
oMSTORE: "MSTORE",
|
||||||
oSTORE: "STORE",
|
oSLOAD: "SLOAD",
|
||||||
|
oSSTORE: "SSTORE",
|
||||||
oJMP: "JMP",
|
oJMP: "JMP",
|
||||||
oJMPI: "JMPI",
|
oJMPI: "JMPI",
|
||||||
oIND: "IND",
|
oIND: "IND",
|
||||||
|
Loading…
Reference in New Issue
Block a user