#[repr(u8)]pub enum Opcode {
Show 166 variants
Push0 = 1,
Push1 = 2,
PushInt8 = 3,
PushInt = 4,
PushStr = 5,
PushLst = 6,
PushObj = 7,
PushNil = 8,
PushTrue = 9,
PushPropId = 10,
PushFnPtr = 11,
PushStrI = 12,
PushParLst = 13,
MakeLstPar = 14,
PushEnum = 15,
PushBifPtr = 16,
Neg = 32,
BNot = 33,
Add = 34,
Sub = 35,
Mul = 36,
BAnd = 37,
BOr = 38,
Shl = 39,
AShr = 40,
Xor = 41,
Div = 42,
Mod = 43,
Not = 44,
Boolize = 45,
Inc = 46,
Dec = 47,
LShr = 48,
Eq = 64,
Ne = 65,
Lt = 66,
Le = 67,
Gt = 68,
Ge = 69,
RetVal = 80,
RetNil = 81,
RetTrue = 82,
Ret = 84,
NamedArgPtr = 86,
NamedArgTab = 87,
Call = 88,
PtrCall = 89,
GetProp = 96,
CallProp = 97,
PtrCallProp = 98,
GetPropSelf = 99,
CallPropSelf = 100,
PtrCallPropSelf = 101,
ObjGetProp = 102,
ObjCallProp = 103,
GetPropData = 104,
PtrGetPropData = 105,
GetPropLcl1 = 106,
CallPropLcl1 = 107,
GetPropR0 = 108,
CallPropR0 = 109,
Inherit = 114,
PtrInherit = 115,
ExpInherit = 116,
PtrExpInherit = 117,
VarArgc = 118,
Delegate = 119,
PtrDelegate = 120,
Swap2 = 122,
SwapN = 123,
GetArgN0 = 124,
GetArgN1 = 125,
GetArgN2 = 126,
GetArgN3 = 127,
GetLcl1 = 128,
GetLcl2 = 129,
GetArg1 = 130,
GetArg2 = 131,
PushSelf = 132,
GetDbLcl = 133,
GetDbArg = 134,
GetArgc = 135,
Dup = 136,
Disc = 137,
Disc1 = 138,
GetR0 = 139,
GetDbArgc = 140,
Swap = 141,
PushCtxEle = 142,
Dup2 = 143,
Switch = 144,
Jmp = 145,
Jt = 146,
Jf = 147,
Je = 148,
Jne = 149,
Jgt = 150,
Jge = 151,
Jlt = 152,
Jle = 153,
Jst = 154,
Jsf = 155,
LJsr = 156,
LRet = 157,
JNil = 158,
JNotNil = 159,
JR0T = 160,
JR0F = 161,
IterNext = 162,
GetSetLcl1R0 = 163,
GetSetLcl1 = 164,
DupR0 = 165,
GetSpN = 166,
GetLclN0 = 170,
GetLclN1 = 171,
GetLclN2 = 172,
GetLclN3 = 173,
GetLclN4 = 174,
GetLclN5 = 175,
Say = 176,
BuiltinA = 177,
BuiltinB = 178,
BuiltinC = 179,
BuiltinD = 180,
Builtin1 = 181,
Builtin2 = 182,
CallExt = 183,
Throw = 184,
SayVal = 185,
Index = 186,
IdxLcl1Int8 = 187,
IdxInt8 = 188,
New1 = 192,
New2 = 193,
TrNew1 = 194,
TrNew2 = 195,
IncLcl = 208,
DecLcl = 209,
AddILcl1 = 210,
AddILcl4 = 211,
AddToLcl = 212,
SubFromLcl = 213,
ZeroLcl1 = 214,
ZeroLcl2 = 215,
NilLcl1 = 216,
NilLcl2 = 217,
OneLcl1 = 218,
OneLcl2 = 219,
SetLcl1 = 224,
SetLcl2 = 225,
SetArg1 = 226,
SetArg2 = 227,
SetInd = 228,
SetProp = 229,
PtrSetProp = 230,
SetPropSelf = 231,
ObjSetProp = 232,
SetDbLcl = 233,
SetDbArg = 234,
SetSelf = 235,
LoadCtx = 236,
StoreCtx = 237,
SetLcl1R0 = 238,
SetIndLcl1I8 = 239,
Bp = 241,
Nop = 242,
}Expand description
A T3 VM instruction.
Variants§
Push0 = 1
Push1 = 2
PushInt8 = 3
PushInt = 4
PushStr = 5
PushLst = 6
PushObj = 7
PushNil = 8
PushTrue = 9
PushPropId = 10
PushFnPtr = 11
PushStrI = 12
PushParLst = 13
MakeLstPar = 14
PushEnum = 15
PushBifPtr = 16
Neg = 32
BNot = 33
Add = 34
Sub = 35
Mul = 36
BAnd = 37
BOr = 38
Shl = 39
AShr = 40
Xor = 41
Div = 42
Mod = 43
Not = 44
Boolize = 45
Inc = 46
Dec = 47
LShr = 48
Eq = 64
Ne = 65
Lt = 66
Le = 67
Gt = 68
Ge = 69
RetVal = 80
RetNil = 81
RetTrue = 82
Ret = 84
NamedArgPtr = 86
NamedArgTab = 87
Call = 88
PtrCall = 89
GetProp = 96
CallProp = 97
PtrCallProp = 98
GetPropSelf = 99
CallPropSelf = 100
PtrCallPropSelf = 101
ObjGetProp = 102
ObjCallProp = 103
GetPropData = 104
PtrGetPropData = 105
GetPropLcl1 = 106
CallPropLcl1 = 107
GetPropR0 = 108
CallPropR0 = 109
Inherit = 114
PtrInherit = 115
ExpInherit = 116
PtrExpInherit = 117
VarArgc = 118
Delegate = 119
PtrDelegate = 120
Swap2 = 122
SwapN = 123
GetArgN0 = 124
GetArgN1 = 125
GetArgN2 = 126
GetArgN3 = 127
GetLcl1 = 128
GetLcl2 = 129
GetArg1 = 130
GetArg2 = 131
PushSelf = 132
GetDbLcl = 133
GetDbArg = 134
GetArgc = 135
Dup = 136
Disc = 137
Disc1 = 138
GetR0 = 139
GetDbArgc = 140
Swap = 141
PushCtxEle = 142
Dup2 = 143
Switch = 144
Jmp = 145
Jt = 146
Jf = 147
Je = 148
Jne = 149
Jgt = 150
Jge = 151
Jlt = 152
Jle = 153
Jst = 154
Jsf = 155
LJsr = 156
LRet = 157
JNil = 158
JNotNil = 159
JR0T = 160
JR0F = 161
IterNext = 162
GetSetLcl1R0 = 163
GetSetLcl1 = 164
DupR0 = 165
GetSpN = 166
GetLclN0 = 170
GetLclN1 = 171
GetLclN2 = 172
GetLclN3 = 173
GetLclN4 = 174
GetLclN5 = 175
Say = 176
BuiltinA = 177
BuiltinB = 178
BuiltinC = 179
BuiltinD = 180
Builtin1 = 181
Builtin2 = 182
CallExt = 183
Throw = 184
SayVal = 185
Index = 186
IdxLcl1Int8 = 187
IdxInt8 = 188
New1 = 192
New2 = 193
TrNew1 = 194
TrNew2 = 195
IncLcl = 208
DecLcl = 209
AddILcl1 = 210
AddILcl4 = 211
AddToLcl = 212
SubFromLcl = 213
ZeroLcl1 = 214
ZeroLcl2 = 215
NilLcl1 = 216
NilLcl2 = 217
OneLcl1 = 218
OneLcl2 = 219
SetLcl1 = 224
SetLcl2 = 225
SetArg1 = 226
SetArg2 = 227
SetInd = 228
SetProp = 229
PtrSetProp = 230
SetPropSelf = 231
ObjSetProp = 232
SetDbLcl = 233
SetDbArg = 234
SetSelf = 235
LoadCtx = 236
StoreCtx = 237
SetLcl1R0 = 238
SetIndLcl1I8 = 239
Bp = 241
Nop = 242
Implementations§
Source§impl Opcode
impl Opcode
Sourcepub const fn from_byte(byte: u8) -> Option<Self>
pub const fn from_byte(byte: u8) -> Option<Self>
The opcode for a byte, if the byte is a defined instruction.
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The instruction’s mnemonic.
Examples found in repository?
examples/probe.rs (line 27)
8fn main() {
9 let args: Vec<String> = std::env::args().skip(1).collect();
10 let data = std::fs::read(&args[0]).expect("cannot read image");
11 let image = Image::parse(&data).expect("cannot parse image");
12 let address = u32::from_str_radix(args[1].trim_start_matches("0x"), 16).expect("bad address");
13 let count: usize = args.get(2).map_or(40, |n| n.parse().expect("bad count"));
14 let page = image
15 .code_pool
16 .at(address)
17 .expect("address is not in the code pool");
18 println!("{:?}", MethodHeader::parse(page));
19 println!("{:02x?}", &page[..page.len().min(16)]);
20 let mut offset = u32::from(image.entry_point.method_header_size);
21 for _ in 0..count {
22 match decode(page, offset) {
23 Ok(i) => {
24 println!(
25 "{:04x} {:<14} {:?} {:?}",
26 i.offset,
27 i.opcode.name(),
28 i.operands,
29 i.payload
30 );
31 offset += i.len;
32 }
33 Err(error) => {
34 println!("{error}");
35 break;
36 }
37 }
38 }
39}Trait Implementations§
impl Copy for Opcode
impl Eq for Opcode
impl StructuralPartialEq for Opcode
Auto Trait Implementations§
impl Forget for Opcode
impl Freeze for Opcode
impl Move for Opcode
impl RefUnwindSafe for Opcode
impl Send for Opcode
impl Sync for Opcode
impl Unpin for Opcode
impl UnsafeUnpin for Opcode
impl UnwindSafe for Opcode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more