Skip to main content

Instruction

Enum Instruction 

Source
pub enum Instruction {
Show 42 variants Span(u32, u32, u32), Label, FunctionStart, FunctionEnd, Breakpoint, Branch(u32), ConditionalBranch(u32, u32), Return(u32), IndirectCall, Call(u32, u32), Halt, Print, Load(Type, u32), Store(Type, u32), Dup, HeapAlloc(u32), GetItem, HeapDealloc, Const(Value), Add(Type), Sub(Type), Mul(Type), Div(Type), Rem(Type), Neg(Type), Shl(Type), Shr(Type), Rol(Type), Ror(Type), BitAnd(Type), BitOr(Type), BitXor(Type), Not, And, Or, Xor, Eq(Type), Ne(Type), Lt(Type), Gt(Type), Le(Type), Ge(Type),
}
Expand description

#[derive(Parse)] notes:

  • Real .sst syntax uses dot-suffixed types (add.i64, load.i64 0). The parse_helpers::cpu_type / cpu_const_value helpers consume the leading .; that’s why the typed variants set delimiters(open = "", close = "", separator = "") and use #[parse_with] on the Type field.
  • Const(Value::String/FunctionRef/HeapRef), Branch(_), ConditionalBranch(_, _), Call(_, _), and bare ret use symbolic operands that need a shared interner / symbol table not available to a stateless Parse impl. Their parse_with helpers return never_u32 so Instruction::parser() errors on those mnemonics — the Module orchestrator (Item 4 of the migration plan) intercepts them first.
  • Variant order is preserved from the pre-migration layout so derived opcodes stay stable. The single exception: IndirectCall is moved ahead of Call so the prefix-ordering check (callcall_indirect) passes.

Variants§

§

Span(u32, u32, u32)

span file:file_id start:u32 end:u32 span 0 1 2 — three space-separated u32s.

§

Label

Label definition.

§

FunctionStart

func_start <name> — marks function entry. <name> is symbolic and orchestrator-resolved; the unit variant carries no payload.

§

FunctionEnd

func_end <name> — marks function exit (debug only).

§

Breakpoint

breakpoint. Must precede Branch (whose token br would be a prefix of breakpoint).

§

Branch(u32)

br <target> — symbolic. Deferred to orchestrator.

§

ConditionalBranch(u32, u32)

cond_br <true_target>, <false_target> — symbolic. Deferred.

§

Return(u32)

ret (bare) is the form real .sst uses; numeric ret <n> has no precedent so we defer. Orchestrator emits Return(0) for bare ret.

§

IndirectCall

call_indirect. Must precede Call for the prefix check.

§

Call(u32, u32)

call <arity>, <addr> — symbolic addr. Deferred.

§

Halt

halt — stop execution.

§

Print

print — write top-of-stack to stdout.

§

Load(Type, u32)

load.<type> <address> — two fields with single-space separator.

§

Store(Type, u32)

store.<type> <address>.

§

Dup

dup.

§

HeapAlloc(u32)

heap_alloc <n>.

§

GetItem

get_item. Must precede Ge (token geget_item).

§

HeapDealloc

heap_dealloc — pops a HeapRef and marks the slot dead, returning it to the free list for reuse by the next heap_alloc.

§

Const(Value)

const.<type> <literal> — numeric/bool only here. .str/.fn_ref/ .heap_ref are orchestrator-handled.

§

Add(Type)

§

Sub(Type)

§

Mul(Type)

§

Div(Type)

§

Rem(Type)

§

Neg(Type)

§

Shl(Type)

§

Shr(Type)

§

Rol(Type)

§

Ror(Type)

§

BitAnd(Type)

§

BitOr(Type)

§

BitXor(Type)

§

Not

§

And

§

Or

§

Xor

§

Eq(Type)

§

Ne(Type)

§

Lt(Type)

§

Gt(Type)

§

Le(Type)

§

Ge(Type)

Trait Implementations§

Source§

impl CanonicalInstructionSyntax for Instruction

Source§

fn variants() -> &'static [CanonicalInstructionVariantSyntax]

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

Returns a duplicate of the value. Read more
1.0.0 · 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, f: &mut Formatter<'_>) -> Result

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

impl<T: Into<Value>> From<T> for Instruction

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl FromBytesWithOpcode for Instruction

Source§

fn from_bytes_with_opcode<R: Read>(bytes: &mut R, opcode: u8) -> Result<Self>

Source§

impl OpCode for Instruction

Source§

fn width() -> u32

Source§

fn opcode(&self) -> u8

Source§

impl<'src> Parse<'src> for Instruction

Source§

fn parser() -> impl Parser<'src, &'src str, Self, Err<Simple<'src, char>>>

Source§

impl PartialEq for Instruction

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl WriteBytes for Instruction

Source§

fn write_bytes<W: Write>(&self, io: &mut W) -> Result<()>

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

§

impl<T> FromBytes for T
where T: FromBytesWithOpcode,

§

fn from_bytes<R>(bytes: &mut R) -> Result<T, Report>
where R: Read,

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.

§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

§

type Proj<U: 'src> = U

§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a [MaybeRef].
§

impl<T> Themed for T
where T: Display,

§

fn ty(&self) -> Decorated<'_, Self>

§

fn target(&self) -> Decorated<'_, Self>

§

fn keyword(&self) -> Decorated<'_, Self>

§

fn symbol(&self) -> Decorated<'_, Self>

§

fn at_symbol(&self) -> Decorated<'_, Self>

§

fn comment(&self) -> Decorated<'_, Self>

§

fn instruction(&self) -> Decorated<'_, 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 = Infallible

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

impl<T> Instruction for T
where T: OpCode + FromBytes + WriteBytes,

§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,