Enum lucia_lang::opcode::OpCode
source · pub enum OpCode {
Show 49 variants
Pop,
Dup,
DupTwo,
RotTwo,
RotThree,
LoadLocal(usize),
LoadGlobal(usize),
LoadUpvalue(usize),
LoadConst(usize),
StoreLocal(usize),
StoreGlobal(usize),
StoreUpvalue(usize),
Import(usize),
ImportFrom(usize),
ImportGlob,
BuildTable(usize),
BuildList(usize),
GetAttr,
GetItem,
GetMeta,
SetAttr,
SetItem,
SetMeta,
Neg,
Not,
Add,
Sub,
Mul,
Div,
Mod,
Eq,
Ne,
Gt,
Ge,
Lt,
Le,
Is,
For(JumpTarget),
Jump(JumpTarget),
JumpIfNull(JumpTarget),
JumpPopIfFalse(JumpTarget),
JumpIfTureOrPop(JumpTarget),
JumpIfFalseOrPop(JumpTarget),
Call(usize),
TryCall(usize),
Return,
Throw,
ReturnCall(usize),
JumpTarget(JumpTarget),
}Expand description
The operation code.
Variants§
Pop
Removes the top-of-stack (TOS) item.
Dup
Duplicates the reference on top of the stack.
DupTwo
Duplicates the two references on top of the stack, leaving them in the same order.
RotTwo
Swaps the two top-most stack items.
RotThree
Lifts second and third stack item one position up, moves top down to position three.
LoadLocal(usize)
Pushes the value associated with local_names[namei] onto the stack.
LoadGlobal(usize)
Pushes the value associated with global_names[namei] onto the stack.
LoadUpvalue(usize)
Pushes the value associated with upvalue_names[namei] onto the stack.
LoadConst(usize)
Pushes consts[consti] onto the stack.
StoreLocal(usize)
Stores TOS into the local_names[namei].
StoreGlobal(usize)
Stores TOS into the global_names[namei].
StoreUpvalue(usize)
Stores TOS into the upvalue_names[namei].
Import(usize)
Imports the module consts[consti] and pushed it onto the stack.
ImportFrom(usize)
Loads the attribute consts[consti] the module found in TOS and pushed it onto the stack.
ImportGlob
LoLoads all symbols from the module TOS to the global namespace.
BuildTable(usize)
Pushes a new table onto the stack. Pops 2 * count items to build table.
BuildList(usize)
Pushes a new list onto the stack. Pops count items to build list.
GetAttr
Implements TOS = TOS1::TOS.
GetItem
Implements TOS = TOS1[TOS].
GetMeta
Implements TOS = TOS[#].
SetAttr
Implements TOS1::TOS = TOS2.
SetItem
Implements TOS1[TOS] = TOS2.
SetMeta
Implements TOS[#] = TOS1.
Neg
Implements TOS = -TOS.
Not
Implements TOS = not TOS.
Add
Implements TOS = TOS1 + TOS.
Sub
Implements TOS = TOS1 - TOS.
Mul
Implements TOS = TOS1 * TOS.
Div
Implements TOS = TOS1 / TOS.
Mod
Implements TOS = TOS1 % TOS.
Eq
Implements TOS = TOS1 == TOS.
Ne
Implements TOS = TOS1 != TOS.
Gt
Implements TOS = TOS1 > TOS.
Ge
Implements TOS = TOS1 >= TOS.
Lt
Implements TOS = TOS1 < TOS.
Le
Implements TOS = TOS1 <= TOS.
Is
Implements TOS = TOS1 is TOS.
For(JumpTarget)
If TOS is iterable or callable, call TOS and get the return value, if the return value if null, jump to target,
else push the return value onto the stack. Used in for statement.
Jump(JumpTarget)
Sets the bytecode counter to target.
JumpIfNull(JumpTarget)
If TOS is null, sets the bytecode counter to target.
JumpPopIfFalse(JumpTarget)
If TOS is false, sets the bytecode counter to target. TOS is popped.
JumpIfTureOrPop(JumpTarget)
If TOS is true, sets the bytecode counter to target and leaves TOS on the stack. Otherwise, TOS is popped.
JumpIfFalseOrPop(JumpTarget)
If TOS is false, sets the bytecode counter to target and leaves TOS on the stack. Otherwise, TOS is popped.
Call(usize)
Pops numbers of item for function arguments, then pop an callable value and call it.
TryCall(usize)
Call with a shortcut for propagating errors.
Return
Returns with TOS to the caller of the function.
Throw
Returns with TOS as a error.
ReturnCall(usize)
Same as “Call(usize); Return;”, this is for tail call optimization.
JumpTarget(JumpTarget)
A jump target, only used during code generation.
Trait Implementations§
source§impl Ord for OpCode
impl Ord for OpCode
source§impl PartialEq<OpCode> for OpCode
impl PartialEq<OpCode> for OpCode
source§impl PartialOrd<OpCode> for OpCode
impl PartialOrd<OpCode> for OpCode
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Eq for OpCode
impl StructuralEq for OpCode
impl StructuralPartialEq for OpCode
Auto Trait Implementations§
impl RefUnwindSafe for OpCode
impl Send for OpCode
impl Sync for OpCode
impl Unpin for OpCode
impl UnwindSafe for OpCode
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.