Skip to main content

Opcode

Enum Opcode 

Source
#[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

Source

pub const ALL: &'static [Opcode]

Every defined opcode, in numeric order.

Source

pub const fn from_byte(byte: u8) -> Option<Self>

The opcode for a byte, if the byte is a defined instruction.

Source

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}
Source

pub const fn layout(self) -> Layout

How the instruction’s operands are laid out.

Trait Implementations§

Source§

impl Clone for Opcode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Opcode

Source§

impl Debug for Opcode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Opcode

Source§

impl Hash for Opcode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Opcode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.