#[repr(u8)]pub enum Opcode {
Show 44 variants
Constant = 0,
Add = 1,
Pop = 2,
Sub = 3,
Mul = 4,
Div = 5,
True = 6,
False = 7,
Equal = 8,
NotEqual = 9,
GreaterThan = 10,
LessThan = 11,
Minus = 12,
Bang = 13,
CondJump = 14,
Jump = 15,
Unit = 16,
SetGlobal = 17,
GetGlobal = 18,
Vector = 19,
Map = 20,
Index = 21,
Call = 22,
ReturnValue = 23,
Return = 24,
GetLocal = 25,
SetLocal = 26,
GetBuiltin = 27,
Closure = 28,
GetFree = 29,
CurrentClosure = 30,
Convert = 31,
Construct = 32,
GetField = 33,
MatchTag = 34,
Mod = 35,
BitAnd = 36,
BitOr = 37,
BitXor = 38,
Shl = 39,
Shr = 40,
MakeRange = 41,
MakeRangeInclusive = 42,
Tuple = 43,
}Expand description
Bytecode operation codes.
Each opcode represents a single VM instruction. Opcodes are encoded as single bytes, with optional operands following in big-endian format.
Variants§
Constant = 0
Push a constant onto the stack. Operands: u16 - index into the constant pool
Add = 1
Add two values from the stack. Operands: none
Pop = 2
Pop value from the stack. Operands: none
Sub = 3
Subtract two values from the stack. Operands: none
Mul = 4
Multiply two values from the stack. Operands: none
Div = 5
Divide two values from the stack. Operands: none
True = 6
Push true onto the stack.
Operands: none
False = 7
Push false onto the stack.
Operands: none
Equal = 8
Test equality of two stack values. Operands: none
NotEqual = 9
Test inequality of two stack values. Operands: none
GreaterThan = 10
Test if first value is greater than second. Operands: none
LessThan = 11
Test if first value is less than second. Operands: none
Minus = 12
Negate a value (unary minus). Operands: none
Bang = 13
Logical NOT operation. Operands: none
CondJump = 14
Conditional jump: pop value and jump to target address if not truthy. Operands: u16 - jump target address
Jump = 15
Unconditional jump to target address. Operands: u16 - jump target address
Unit = 16
Push the unit value () onto the stack.
Operands: none
SetGlobal = 17
Store a value in a global binding. Operands: u16 - global variable index
GetGlobal = 18
Load a value from a global binding. Operands: u16 - global variable index
Vector = 19
Build a vector from the top N stack elements. Operands: u16 - number of elements
Map = 20
Build a map from the top N stack elements (key-value pairs). Operands: u16 - total number of elements (keys + values)
Index = 21
Index into a vector or map. Pops index and container, pushes result. Operands: none
Call = 22
Call a function. Pops function and arguments from the stack. Operands: u8 - number of arguments
ReturnValue = 23
Return from a function with a value on top of the stack. Operands: none
Return = 24
Return from a function with no explicit return value (implicit unit ()).
Operands: none
GetLocal = 25
Load a local binding onto the stack. Operands: u8 - local variable index
SetLocal = 26
Store a value in a local binding. Operands: u8 - local variable index
GetBuiltin = 27
Load a built-in function onto the stack. Operands: u8 - builtin function index
Closure = 28
Create a closure from a compiled function and captured free variables. Operands: [u16, u8] - constant pool index of the function, number of free variables
GetFree = 29
Load a free variable from the current closure’s captured environment. Operands: u8 - free variable index
CurrentClosure = 30
Push the current closure onto the stack for recursive self-reference. Operands: none
Convert = 31
Construct = 32
Construct a struct or enum variant from the top N stack elements.
Operands: [u16, u8]
u16: packed type index encoding(registry_index << 8) | variant_tag. The high 8 bits select the entry in the type registry; the low 8 bits carry the variant tag (0 for structs, 0..255 for enum variants).u8: number of field values to pop from the stack.
GetField = 33
Read a field from a struct on top of the stack. Operands: u16 - field index
MatchTag = 34
Read the variant tag from an enum on top of the stack (peek, no pop). If the tag matches, execution continues to the next instruction; otherwise the instruction pointer jumps to the mismatch target.
Operands: [u16, u16]
u16: expected variant tag. Tags are limited to 0..255 byMAX_ENUM_VARIANTSbut encoded asu16for operand-width uniformity with other two-byte operands.u16: jump target address on mismatch.
Mod = 35
Compute the remainder of two values from the stack. Operands: none
BitAnd = 36
Bitwise AND of two values from the stack. Operands: none
BitOr = 37
Bitwise OR of two values from the stack. Operands: none
BitXor = 38
Bitwise XOR of two values from the stack. Operands: none
Shl = 39
Left shift of two values from the stack. Operands: none
Shr = 40
Right shift of two values from the stack. Operands: none
MakeRange = 41
Construct a half-open Range from two i64 values on the stack.
Pops end then start, pushes Value::Range(start, end).
Operands: none
MakeRangeInclusive = 42
Construct an inclusive RangeInclusive from two i64 values on the stack.
Pops end then start, pushes Value::RangeInclusive(start, end).
Operands: none
Tuple = 43
Build a tuple from the top N stack elements. Operands: u16 - number of elements
Implementations§
Trait Implementations§
impl Copy for Opcode
impl Eq for Opcode
impl StructuralPartialEq for Opcode
Auto Trait Implementations§
impl Freeze 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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.