lua_bytecode/
opcode.rs

1#[repr(u8)]
2#[derive(Copy, Clone, Debug, PartialEq, Eq)]
3#[cfg(feature = "lua51")]
4pub enum LuaOpcode {
5    Move,
6    LoadK,
7    LoadBool,
8    LoadNil,
9    GetUpval,
10
11    GetGlobal,
12    GetTable,
13
14    SetGlobal,
15    SetUpval,
16    SetTable,
17
18    NewTable,
19
20    Self_,
21
22    Add,
23    Sub,
24    Mul,
25    Div,
26    Mod,
27    Pow,
28    Unm,
29    Not,
30    Len,
31
32    Concat,
33
34    Jmp,
35
36    Eq,
37    Lt,
38    Le,
39
40    Test,
41    TestSet,
42
43    Call,
44    TailCall,
45    Return,
46
47    ForLoop,
48    ForPrep,
49
50    TForLoop,
51    SetList,
52
53    Close,
54    Closure,
55
56    Vararg,
57}
58
59#[repr(u8)]
60#[derive(Copy, Clone, Debug, PartialEq, Eq)]
61#[cfg(feature = "luau")]
62pub enum LuauOpcode {
63    Nop,
64    Break,
65    LoadNil,
66    LoadB,
67    LoadN,
68    LoadK,
69    Move,
70    GetGlobal,
71    SetGlobal,
72    GetUpval,
73    SetUpval,
74    CloseUpvals,
75    GetImport,
76    GetTable,
77    SetTable,
78    GetTableKs,
79    SetTableKs,
80    GetTableN,
81    SetTableN,
82    NewClosure,
83    NameCall,
84    Call,
85    Return,
86    Jump,
87    JumpBack,
88    JumpIf,
89    JumpIfNot,
90    JumpIfEq,
91    JumpIfLe,
92    JumpIfLt,
93    JumpIfNotEq,
94    JumpIfNotLe,
95    JumpIfNotLt,
96    Add,
97    Sub,
98    Mul,
99    Div,
100    Mod,
101    Pow,
102    AddK,
103    SubK,
104    MulK,
105    DivK,
106    ModK,
107    PowK,
108    And,
109    Or,
110    AndK,
111    OrK,
112    Concat,
113    Not,
114    Minus,
115    Length,
116    NewTable,
117    DupTable,
118    SetList,
119    ForNPrep,
120    ForNLoop,
121    ForGLoop,
122    ForGPrepInext,
123    FastCall3,
124    ForGPrepNext,
125    NativeCall,
126    GetVarargs,
127    DupClosure,
128    PrepVarargs,
129    LoadKx,
130    JumpX,
131    FastCall,
132    Coverage,
133    Capture,
134    SubRk,
135    DivRk,
136    FastCall1,
137    FastCall2,
138    FastCall2K,
139    ForGPrep,
140    JumpXeqkNil,
141    JumpXeqkB,
142    JumpXeqkN,
143    JumpXeqkS,
144    IDiv,
145    IDivK,
146}
147
148#[cfg(feature = "lua51")]
149impl LuaOpcode {
150    pub(crate) fn index(op: u8) -> LuaOpcode {
151        unsafe { std::mem::transmute(op) }
152    }
153}
154
155#[cfg(feature = "luau")]
156impl LuauOpcode {
157    pub(crate) fn index(op: u8) -> LuauOpcode {
158        unsafe { std::mem::transmute(op) }
159    }
160}
161
162#[derive(Clone, Copy, Debug, PartialEq, Eq)]
163pub enum OpCode {
164    #[cfg(feature = "lua51")]
165    LuaOpcode(LuaOpcode),
166    #[cfg(feature = "luau")]
167    LuauOpcode(LuauOpcode),
168}