pub enum OpCode<'s> {
Show 15 variants
Call {
function: usize,
arguments: usize,
destination: usize,
},
IndexRead {
indexee: usize,
index: usize,
destination: usize,
},
IndexWrite {
indexee: usize,
index: usize,
value: usize,
},
Create {
destination: usize,
},
BinaryOperation {
left: usize,
right: usize,
operation: BinaryOperation,
destination: usize,
},
UnaryOperation {
operand: usize,
operation: UnaryOperation,
destination: usize,
},
Jump {
operation: u64,
if: Option<usize>,
},
Return {
result: usize,
},
ReAssign {
actor: usize,
destination: usize,
},
LoadConst {
constant: u16,
register: usize,
},
LoadGlobal {
global: &'s str,
register: usize,
},
SaveGlobal {
register: usize,
global: &'s str,
},
LoadUpValue {
up_value: usize,
register: usize,
},
SaveUpValue {
register: usize,
up_value: usize,
},
NoOp,
}
Expand description
The operation codes used within the lua virtual machine. All lua code is compiled to blocks of opcodes. Opcodes are the primitive block of “action” (lua code ran from this vm cannot perform any actions more specific than what these opcodes can provide). Each opcode does a different thing, but most opcodes operate with memory directly from the local scope via symbols.
Typically, the lua compiler will use temporary variable names that cannot be accessed from lua directly. All of these temporary variables start with a left parenthesis, because that makes these variables impossible to access or alter accidentally in lua. Theoretically, you can use methods from the debug module to access these temporary variables, but tampering with them won’t do much more than corrupt the state of the currently executing function.
Variants§
Call
Calls a function with the name [function], with the arguments array [arguments], and stores the result array in [destination]. [arguments] must be a lua array (a table, typically with numbered keys starting from 1), or else an error will be thrown.
[destination_local] determines if the result will be stored to the local scope or global scope.
Fields
function: usize
The name of the function, in scope, to be called. Must be a function or else an error will be thrown.
IndexRead
Indexes into the object with the name [indexee], with index [index], and stores the result in [destination].
[destination_local] determines if the result will be stored to the local scope or global scope.
Fields
IndexWrite
Indexes into the object with the name [indexee], with index [index], and writes value into [indexee].
Fields
Create
Creates a new empty table at [destination].
[destination_local] determines if the new table will be stored to the local scope or global scope.
BinaryOperation
UnaryOperation
Jump
Jumps unconditionally to [operation], or conditionally if the name of a condition is specified in [r#if]. The jump operation is performed in number of opcodes, not bytes.
Fields
Return
ReAssign
LoadConst
Loads a value from the constant pool at index constant to [destination].
[destination_local] determines if the constant will be stored to the local scope or global scope.
Fields
LoadGlobal
SaveGlobal
LoadUpValue
SaveUpValue
NoOp
Trait Implementations§
impl<'s> Eq for OpCode<'s>
impl<'s> StructuralPartialEq for OpCode<'s>
Auto Trait Implementations§
impl<'s> Freeze for OpCode<'s>
impl<'s> RefUnwindSafe for OpCode<'s>
impl<'s> Send for OpCode<'s>
impl<'s> Sync for OpCode<'s>
impl<'s> Unpin for OpCode<'s>
impl<'s> UnwindSafe for OpCode<'s>
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
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more