github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/core/wavm/opcodes.go (about) 1 package wavm 2 3 import ops "github.com/vntchain/vnt-wasm/wasm/operators" 4 5 // OpCode is an WAVM opcode 6 7 var ( 8 OpReturn byte = 0x0f 9 OpBrTable byte = 0x0e 10 ) 11 12 type OpCode struct { 13 Op byte 14 FuncName string 15 } 16 17 func (op OpCode) IsPush() bool { 18 return false 19 } 20 21 func (op OpCode) String() string { 22 if op.FuncName == "" { 23 switch op.Op { 24 case OpReturn: 25 return "Return" 26 case OpJmp: 27 return "Jmp" 28 case OpJmpZ: 29 return "JmpZ" 30 case OpJmpNz: 31 return "JmpNz" 32 case OpBrTable: 33 return "BrTable" 34 case OpDiscard: 35 return "Discard" 36 case OpDiscardPreserveTop: 37 return "DiscardPreserveTop" 38 default: 39 o, err := ops.New(op.Op) 40 if err != nil { 41 return "" 42 } 43 return o.Name 44 } 45 } else { 46 return op.FuncName 47 } 48 } 49 50 func (op OpCode) Byte() byte { 51 return op.Op 52 }