Skip to main content

Instruction

Enum Instruction 

Source
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: pop argc, push 1 (net 1 - argc).
  • Closure: pops captures, pushes 1 (net 1 - captures).
  • Call: pops argc arguments plus the callee, pushes 1 (net -argc).
  • CallStatic: pops argc, pushes 1 (net 1 - 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: pops count, pushes 1 (net 1 - 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.

Fields

§target: u32
§argc: u8
§

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.

Fields

§prototype: u16
§captures: u8
§

Call

Pops argc arguments and then the callee, invokes the function value through the shared call_function boundary, and pushes the result.

Fields

§argc: u8
§

CallStatic

Pops argc arguments and calls prototype directly, copying the current frame’s capture slots as the callee’s captures (defn self-recursion).

Fields

§prototype: u16
§argc: u8
§

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).

Fields

§name: u32
§metadata: Option<u16>
§

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.

Fields

§name: u32
§count: u8
§

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.

Fields

§name: u32
§metadata: Option<u16>
§

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.

Fields

§method: u32
§argc: u8
§

ProtocolCall

Pops argc protocol arguments, including the receiver, and dispatches the canonical protocol method through the active protocol registry.

Fields

§target: u32
§argc: u8
§

Return

Returns the top of the stack as the function result.

Implementations§

Source§

impl Instruction

Source

pub fn jump_target(&self) -> Option<u32>

The jump target, when the instruction transfers control.

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Instruction

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more