pub enum Instruction {
Show 44 variants
Constant(u32),
Nil,
True,
False,
LoadLocal(u16),
StoreLocal(u16),
Pop,
Dup,
IntrinsicCall {
target: u32,
argc: u8,
},
Jump(u32),
JumpIfFalse(u32),
Closure {
prototype: u16,
captures: u8,
},
Call {
argc: u8,
},
CallStatic {
prototype: u16,
argc: u8,
},
Throw,
Rethrow,
GetGlobal(u32),
DefGlobal {
name: u32,
metadata: Option<u16>,
},
SetGlobal(u32),
VarGlobal(u32),
DeclareGlobal(u32),
MutableFieldGet(u32),
MutableFieldSet(u32),
InstanceOf,
MakeMultiArity {
name: u32,
count: u8,
},
BuildVector(u16),
BuildMap(u16),
BuildSet(u16),
BuildList(u16),
ConcatList(u16),
ToVector,
DefMacro {
name: u32,
metadata: Option<u16>,
},
IntrinsicValue(u32),
BuiltinValue(u32),
NamespaceValue(u32),
NamespaceOperation(u32),
DynamicBind(u32),
DynamicUnbind(u32),
Await,
Yield,
HostCall,
DotCall {
method: u32,
argc: u8,
},
ProtocolCall {
target: u32,
argc: u8,
},
Return,
}Expand description
One VM instruction.
Stack effects (validated before execution):
Constant,Nil,True,False,LoadLocal: push 1.StoreLocal,Pop,JumpIfFalse: pop 1.IntrinsicCall,ProtocolCall: popargc, push 1 (net1 - argc).Closure: popscaptures, pushes 1 (net1 - captures).Call: popsargcarguments plus the callee, pushes 1 (net-argc).CallStatic: popsargc, pushes 1 (net1 - argc).Jump: no change.Throw,Rethrow: pop 1; terminal (unwind).GetGlobal,VarGlobal,DeclareGlobal: push 1.DefGlobal,SetGlobal,MutableFieldGet: pop 1, push 1 (net 0).MutableFieldSet: pops receiver and replacement, pushes replacement (net -1).InstanceOf: pops 2, pushes 1 (net -1).MakeMultiArity: popscount, pushes 1 (net1 - count).Return: terminal; requires stack height exactly 1.
Variants§
Constant(u32)
Pushes constants[index] onto the operand stack.
Nil
Pushes Value::Nil.
True
Pushes Value::Bool(true).
False
Pushes Value::Bool(false).
LoadLocal(u16)
Pushes the value of local slot slot.
StoreLocal(u16)
Pops the top of the stack into local slot slot.
Pop
Discards the top of the stack.
Dup
Duplicates the top stack value.
IntrinsicCall
Pops argc arguments and invokes the named runtime intrinsic.
Jump(u32)
Unconditional jump to an absolute instruction index.
JumpIfFalse(u32)
Pops the condition and jumps when it is not truthy
(Value::truthy: only nil and false are false).
Closure
Pops captures captured values and pushes a function value for
prototype.
Call
Pops argc arguments and then the callee, invokes the function
value through the shared call_function boundary, and pushes the
result.
CallStatic
Pops argc arguments and calls prototype directly, copying the
current frame’s capture slots as the callee’s captures (defn
self-recursion).
Throw
Pops one value and raises it as a guest exception through the
shared core::thrown_error boundary. Terminal: unwinds to the
innermost covering try entry or fails the run.
Rethrow
Pops a string and raises that exact message without touching the thrown-value side channel, preserving error identity across an unmatched finally boundary. Terminal; only emitted in finally resume sequences.
GetGlobal(u32)
Pushes the dereferenced value of the var named by the string
constant at constants[index], resolved through the namespace
registry at execution time.
DefGlobal
Pops a value, interns it as a Var in the current namespace
(optional hara metadata from the program’s var-metadata table),
and pushes the interned Var back (def returns the Var).
SetGlobal(u32)
Pops a value, resets the root of the var named by the string
constant at constants[index], and pushes the value.
VarGlobal(u32)
Pushes the Value::Var named by the string constant at
constants[index] (var / #').
DeclareGlobal(u32)
Interns a nil var for the string constant at constants[index]
when the name is not already bound (declare), pushing nil.
Never resets an existing var.
MutableFieldGet(u32)
Pops a mutable instance and pushes the declared field value named by
the string constant at constants[index] (field).
MutableFieldSet(u32)
Pops the replacement and mutable receiver, performs one direct field
mutation, and pushes the replacement value (set! field place).
InstanceOf
Pops the value and then a named type, and pushes whether the
value is an instance (instance?).
MakeMultiArity
Pops count function values and pushes the arity dispatcher
named by the string constant at constants[name], built through
the shared core::arity_dispatcher boundary.
BuildVector(u16)
Pops count values and constructs a compact tuple, upgrading to a vector above arity 8.
BuildMap(u16)
Pops pairs * 2 alternating keys and values and constructs an
persistent hash map.
BuildSet(u16)
Pops count values and constructs an insertion-ordered set.
BuildList(u16)
ConcatList(u16)
ToVector
DefMacro
Pops a function value, interns it as a macro Var, registers it in the active Runtime macro registry, and pushes the function back.
IntrinsicValue(u32)
Pushes a first-class callable for a runtime intrinsic.
BuiltinValue(u32)
Pushes a first-class callable implemented by the structural runtime.
NamespaceValue(u32)
Pushes a namespace value resolved from the current namespace’s alias table (or from the registry by name), matching the evaluator’s bare namespace alias form.
NamespaceOperation(u32)
Applies a validated ns, ns+, or require form retained in the
constant pool and pushes its result. This is the bytecode management
seam used for nested namespace operations; top-level declarations are
prepared by the runtime before ordinary code is compiled.
DynamicBind(u32)
Binds a dynamic Var to the value on top of the stack and leaves nil.
DynamicUnbind(u32)
Removes the most recent binding for a dynamic Var and leaves nil.
Await
Replaces a settled promise with its value, raises a rejection, or suspends the current VM fiber while preserving the complete machine.
Yield
Suspends the current bytecode coroutine with the value on top of the stack. Resumption replaces it with the caller-supplied value.
HostCall
Pops service, method, and argument-vector values and returns the provider’s ordinary Promise value.
DotCall
Invokes a native collection method with an evaluated receiver and arguments.
ProtocolCall
Pops argc protocol arguments, including the receiver, and dispatches
the canonical protocol method through the active protocol registry.
Return
Returns the top of the stack as the function result.
Implementations§
Source§impl Instruction
impl Instruction
Sourcepub fn jump_target(&self) -> Option<u32>
pub fn jump_target(&self) -> Option<u32>
The jump target, when the instruction transfers control.
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Instruction
impl Debug for Instruction
Source§impl Display for Instruction
impl Display for Instruction
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
impl StructuralPartialEq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnsafeUnpin for Instruction
impl UnwindSafe for Instruction
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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