pub enum Instruction {
Show 45 variants
LPush(u16),
GPush(u16),
CPush(u16),
LMove(u16),
GMove(u16),
Drop,
Dup,
Get,
RGet,
Set,
Add,
Sub,
Mul,
Div,
Pow,
Rem,
Shl,
Shr,
And,
Or,
XOr,
Not,
Eq,
Ne,
Ge,
Gt,
Le,
Lt,
Jmp(u16),
Jt(u16),
Jf(u16),
Call(u16, u8),
LCall(u16, u8),
Ret,
Interrupt(u16),
Conv(u16),
Import,
NImport,
Box,
Slice,
IterCreate,
IterCreateRanged,
IterHasNext,
IterNext,
IterReverse,
}Expand description
Definition of the bytecode
Variants§
LPush(u16)
Push local variable.
GPush(u16)
Push global variable.
CPush(u16)
Push constant.
LMove(u16)
Store into local variable.
GMove(u16)
Store into global variable.
Drop
Drops the value on top of stack.
Dup
Duplicates top of stack.
Get
Get first argument as key from second argument and push it.
RGet
Get first argument as key from second argument by reference and push it.
Set
Write second argument into first argument which must be a reference.
Add
= first + second
Sub
= first - second
Mul
= first * second
Div
= first / second
Pow
= first ** second
Rem
= first % second
Shl
Logical shift left first by second places.
Shr
Logical shift right first by second places.
And
Logical and for Bool, Bitwise and for Int.
Or
Logical or for Bool, Bitwise or for Int.
XOr
Logical xor for Bool, Bitwise xor for Int.
Not
Logical not for Bool, Bitwise not for Int.
Eq
= first == second
Ne
= first != second
Ge
= first >= second
Gt
= first > second
Le
= first <= second
Lt
= first < second
Jmp(u16)
Jump to instruction offset.
Jt(u16)
Jump to instruction offset if top of stack is true.
Jf(u16)
Jump to instruction offset if top of stack is false.
Call(u16, u8)
Call function with ident index, argn.
LCall(u16, u8)
Call a function in the same module.
Ret
Return early from a code object.
Interrupt(u16)
Trigger interrupt n.
Conv(u16)
Convert top of stack into type. See Value::type_id.
Import
Take top of stack as name of module to load and import functions without module prefix as well.
NImport
Take top of stack as name of module to import. Function name will be padded using the import hook.
Box
Turn the value on stack into a referenceable value. Lists and dicts are boxed deeply.
Slice
Create a new list from the first argument on stack. Second is starting index or nil, third is end index (exclusive) or nil.
IterCreate
Create a new iterator from the first argument on stack.
IterCreateRanged
Create a new ranged iterator using the first argument as from and second argument as to.
on of the arguments is allowed to be nil.
IterHasNext
Consumes the iterator on top of stack and leaves a bool on top if the iterator has another element.
IterNext
Consumes the iterator on top of stack and returns the next value if any.
IterReverse
Consumes the iterator on top of stack and create a new one in reverse.
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more