pub enum InstData {
Show 64 variants
IntConst(u64),
FloatConst(u64),
BoolConst(bool),
StringConst(Spur),
UnitConst,
Add {
lhs: InstRef,
rhs: InstRef,
},
Sub {
lhs: InstRef,
rhs: InstRef,
},
Mul {
lhs: InstRef,
rhs: InstRef,
},
Div {
lhs: InstRef,
rhs: InstRef,
},
Mod {
lhs: InstRef,
rhs: InstRef,
},
Eq {
lhs: InstRef,
rhs: InstRef,
},
Ne {
lhs: InstRef,
rhs: InstRef,
},
Lt {
lhs: InstRef,
rhs: InstRef,
},
Gt {
lhs: InstRef,
rhs: InstRef,
},
Le {
lhs: InstRef,
rhs: InstRef,
},
Ge {
lhs: InstRef,
rhs: InstRef,
},
And {
lhs: InstRef,
rhs: InstRef,
},
Or {
lhs: InstRef,
rhs: InstRef,
},
BitAnd {
lhs: InstRef,
rhs: InstRef,
},
BitOr {
lhs: InstRef,
rhs: InstRef,
},
BitXor {
lhs: InstRef,
rhs: InstRef,
},
Shl {
lhs: InstRef,
rhs: InstRef,
},
Shr {
lhs: InstRef,
rhs: InstRef,
},
Neg {
operand: InstRef,
},
Not {
operand: InstRef,
},
BitNot {
operand: InstRef,
},
Branch {
cond: InstRef,
then_block: InstRef,
else_block: Option<InstRef>,
},
Loop {
cond: InstRef,
body: InstRef,
},
For {
binding: Spur,
is_mut: bool,
iterable: InstRef,
body: InstRef,
},
InfiniteLoop {
body: InstRef,
},
Match {
scrutinee: InstRef,
arms_start: u32,
arms_len: u32,
},
Break,
Continue,
FnDecl {
directives_start: u32,
directives_len: u32,
is_pub: bool,
is_unchecked: bool,
name: Spur,
params_start: u32,
params_len: u32,
return_type: Spur,
body: InstRef,
has_self: bool,
},
ConstDecl {
directives_start: u32,
directives_len: u32,
is_pub: bool,
name: Spur,
ty: Option<Spur>,
init: InstRef,
},
Call {
name: Spur,
args_start: u32,
args_len: u32,
},
Intrinsic {
name: Spur,
args_start: u32,
args_len: u32,
},
TypeIntrinsic {
name: Spur,
type_arg: Spur,
},
ParamRef {
index: u32,
name: Spur,
},
Ret(Option<InstRef>),
Block {
extra_start: u32,
len: u32,
},
Alloc {
directives_start: u32,
directives_len: u32,
name: Option<Spur>,
is_mut: bool,
ty: Option<Spur>,
init: InstRef,
},
StructDestructure {
type_name: Spur,
fields_start: u32,
fields_len: u32,
init: InstRef,
},
VarRef {
name: Spur,
},
Assign {
name: Spur,
value: InstRef,
},
StructDecl {
directives_start: u32,
directives_len: u32,
is_pub: bool,
is_linear: bool,
name: Spur,
fields_start: u32,
fields_len: u32,
methods_start: u32,
methods_len: u32,
},
StructInit {
module: Option<InstRef>,
type_name: Spur,
fields_start: u32,
fields_len: u32,
},
FieldGet {
base: InstRef,
field: Spur,
},
FieldSet {
base: InstRef,
field: Spur,
value: InstRef,
},
EnumDecl {
is_pub: bool,
name: Spur,
variants_start: u32,
variants_len: u32,
},
EnumVariant {
module: Option<InstRef>,
type_name: Spur,
variant: Spur,
},
EnumStructVariant {
module: Option<InstRef>,
type_name: Spur,
variant: Spur,
fields_start: u32,
fields_len: u32,
},
ArrayInit {
elems_start: u32,
elems_len: u32,
},
IndexGet {
base: InstRef,
index: InstRef,
},
IndexSet {
base: InstRef,
index: InstRef,
value: InstRef,
},
MethodCall {
receiver: InstRef,
method: Spur,
args_start: u32,
args_len: u32,
},
AssocFnCall {
type_name: Spur,
function: Spur,
args_start: u32,
args_len: u32,
},
DropFnDecl {
type_name: Spur,
body: InstRef,
},
Comptime {
expr: InstRef,
},
ComptimeUnrollFor {
binding: Spur,
iterable: InstRef,
body: InstRef,
},
Checked {
expr: InstRef,
},
TypeConst {
type_name: Spur,
},
AnonStructType {
fields_start: u32,
fields_len: u32,
methods_start: u32,
methods_len: u32,
},
AnonEnumType {
variants_start: u32,
variants_len: u32,
methods_start: u32,
methods_len: u32,
},
}Expand description
Instruction data - the actual operation.
Variants§
IntConst(u64)
Integer constant
FloatConst(u64)
Floating-point constant, stored as f64 bits for Eq/Hash/Copy compatibility.
Use f64::from_bits() to recover the value.
BoolConst(bool)
Boolean constant
StringConst(Spur)
String constant (interned string content)
UnitConst
Unit constant (for blocks that produce unit type)
Add
Addition: lhs + rhs
Sub
Subtraction: lhs - rhs
Mul
Multiplication: lhs * rhs
Div
Division: lhs / rhs
Mod
Modulo: lhs % rhs
Eq
Equality: lhs == rhs
Ne
Inequality: lhs != rhs
Lt
Less than: lhs < rhs
Gt
Greater than: lhs > rhs
Le
Less than or equal: lhs <= rhs
Ge
Greater than or equal: lhs >= rhs
And
Logical AND: lhs && rhs
Or
Logical OR: lhs || rhs
BitAnd
Bitwise AND: lhs & rhs
BitOr
Bitwise OR: lhs | rhs
BitXor
Bitwise XOR: lhs ^ rhs
Shl
Left shift: lhs << rhs
Shr
Right shift: lhs >> rhs (arithmetic for signed, logical for unsigned)
Neg
Negation: -operand
Not
Logical NOT: !operand
BitNot
Bitwise NOT: ~operand
Branch
Branch: if cond then then_block else else_block
Loop
While loop: while cond { body }
For
For-in loop: for [mut] binding in iterable { body }
Fields
binding: SpurThe loop variable name
InfiniteLoop
Infinite loop: loop { body }
Match
Match expression: match scrutinee { pattern => expr, … } Arms are stored in the extra array using add_match_arms/get_match_arms.
Fields
Break
Break: exits the innermost loop
Continue
Continue: jumps to the next iteration of the innermost loop
FnDecl
Function definition Contains: name symbol, parameters, return type symbol, body instruction ref Directives and params are stored in the extra array.
Fields
is_unchecked: boolWhether this function is marked unchecked (can only be called from checked blocks)
name: Spurreturn_type: SpurConstDecl
Constant declaration
Contains: name symbol, optional type, initializer expression ref
Directives are stored in the extra array.
Used for module re-exports: pub const strings = @import("utils/strings.gruel");
Fields
name: SpurConstant name
Call
Function call Args are stored in the extra array using add_call_args/get_call_args.
Fields
name: SpurFunction name
Intrinsic
Intrinsic call with expression arguments (e.g., @dbg) Args are stored in the extra array using add_inst_refs/get_inst_refs.
Fields
name: SpurIntrinsic name (without @)
TypeIntrinsic
Intrinsic call with a type argument (e.g., @size_of, @align_of)
Fields
name: SpurIntrinsic name (without @)
type_arg: SpurType argument (as an interned string, e.g., “i32”, “Point”, “[i32; 4]”)
ParamRef
Reference to a function parameter
Ret(Option<InstRef>)
Return value from function (None for return; in unit-returning functions)
Block
Block of instructions (for function bodies) The result is the last instruction in the block
Fields
Alloc
Local variable declaration: allocates storage and initializes If name is None, this is a wildcard pattern that discards the value Directives are stored in the extra array using add_directives/get_directives.
Fields
StructDestructure
Struct destructuring: let TypeName { fields } = expr;
Fields are stored in the extra array as groups of 4 u32s:
[field_name, binding_name (0 = shorthand), is_wildcard, is_mut]
Fields
type_name: SpurStruct type name
VarRef
Variable reference: reads the value of a variable
Fields
name: SpurVariable name
Assign
Assignment: stores a value into a mutable variable
StructDecl
Struct type declaration Directives, fields, and methods are stored in the extra array.
Fields
name: SpurStruct name
StructInit
Struct literal: creates a new struct instance Fields are stored in the extra array using add_field_inits/get_field_inits.
Fields
module: Option<InstRef>Optional module reference (for qualified struct literals like module.Point { ... })
If Some, the struct is looked up in the module’s exports.
type_name: SpurStruct type name
FieldGet
Field access: reads a field from a struct
FieldSet
Field assignment: writes a value to a struct field
EnumDecl
Enum type declaration Variants are stored in the extra array using add_enum_variant_decls/get_enum_variant_decls. Each variant encodes: [name_spur, field_count, field_type_0, …, field_type_n].
Fields
name: SpurEnum name
EnumVariant
Enum variant: creates a value of an enum type
Fields
module: Option<InstRef>Optional module reference (for qualified paths like module.Color::Red)
If Some, the enum is looked up in the module’s exports.
type_name: SpurEnum type name
variant: SpurVariant name
EnumStructVariant
Enum struct variant construction: Enum::Variant { field: value, ... }
Fields are stored in the extra array using add_field_inits/get_field_inits.
ArrayInit
Array literal: creates a new array from element values Elements are stored in the extra array using add_inst_refs/get_inst_refs.
IndexGet
Array index read: reads an element from an array
IndexSet
Array index write: writes a value to an array element
Fields
MethodCall
Method call: receiver.method(args) Args are stored in the extra array using add_call_args/get_call_args.
Fields
method: SpurMethod name
AssocFnCall
Associated function call: Type::function(args) Args are stored in the extra array using add_call_args/get_call_args.
DropFnDecl
User-defined destructor declaration: drop fn TypeName(self) { … }
Fields
type_name: SpurThe struct type this destructor is for
Comptime
Comptime block expression: comptime { expr } The inner expression must be evaluable at compile time.
ComptimeUnrollFor
Comptime unroll for loop: comptime_unroll for binding in iterable { body } The iterable must be evaluable at compile time. The body is duplicated once per iteration with the binding replaced by each element’s value.
Fields
binding: SpurThe loop variable name
Checked
Checked block expression: checked { expr } Unchecked operations (raw pointer manipulation, calling unchecked functions) are only allowed inside checked blocks.
TypeConst
Type constant: a type used as a value expression (e.g., i32 in identity(i32, 42))
The type_name is the symbol for the type (e.g., “i32”, “bool”).
Fields
type_name: SpurThe type name symbol
AnonStructType
Anonymous struct type: a struct type used as a value expression
(e.g., struct { first: T, second: T, fn method(self) -> T { ... } } in comptime type construction)
Fields are stored in the extra array using add_field_decls/get_field_decls.
Methods are stored as InstRefs to FnDecl instructions in the extra array.
Fields
AnonEnumType
Anonymous enum type: an enum type used as a value expression
(e.g., enum { Some(T), None, fn method(self) -> T { ... } } in comptime type construction)
Variants are stored in the extra array using add_enum_variant_decls/get_enum_variant_decls.
Methods are stored as InstRefs to FnDecl instructions in the extra array.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InstData
impl RefUnwindSafe for InstData
impl Send for InstData
impl Sync for InstData
impl Unpin for InstData
impl UnwindSafe for InstData
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,
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].