InstData

Enum InstData 

Source
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

Fields

§

Sub

Subtraction: lhs - rhs

Fields

§

Mul

Multiplication: lhs * rhs

Fields

§

Div

Division: lhs / rhs

Fields

§

Mod

Modulo: lhs % rhs

Fields

§

Eq

Equality: lhs == rhs

Fields

§

Ne

Inequality: lhs != rhs

Fields

§

Lt

Less than: lhs < rhs

Fields

§

Gt

Greater than: lhs > rhs

Fields

§

Le

Less than or equal: lhs <= rhs

Fields

§

Ge

Greater than or equal: lhs >= rhs

Fields

§

And

Logical AND: lhs && rhs

Fields

§

Or

Logical OR: lhs || rhs

Fields

§

BitAnd

Bitwise AND: lhs & rhs

Fields

§

BitOr

Bitwise OR: lhs | rhs

Fields

§

BitXor

Bitwise XOR: lhs ^ rhs

Fields

§

Shl

Left shift: lhs << rhs

Fields

§

Shr

Right shift: lhs >> rhs (arithmetic for signed, logical for unsigned)

Fields

§

Neg

Negation: -operand

Fields

§operand: InstRef
§

Not

Logical NOT: !operand

Fields

§operand: InstRef
§

BitNot

Bitwise NOT: ~operand

Fields

§operand: InstRef
§

Branch

Branch: if cond then then_block else else_block

Fields

§cond: InstRef
§then_block: InstRef
§else_block: Option<InstRef>
§

Loop

While loop: while cond { body }

Fields

§cond: InstRef
§body: InstRef
§

For

For-in loop: for [mut] binding in iterable { body }

Fields

§binding: Spur

The loop variable name

§is_mut: bool

Whether the loop variable is mutable

§iterable: InstRef

The iterable expression (array or @range result)

§body: InstRef

The loop body

§

InfiniteLoop

Infinite loop: loop { body }

Fields

§body: InstRef
§

Match

Match expression: match scrutinee { pattern => expr, … } Arms are stored in the extra array using add_match_arms/get_match_arms.

Fields

§scrutinee: InstRef

The value being matched

§arms_start: u32

Index into extra data where arms start

§arms_len: u32

Number of match arms

§

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

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§is_pub: bool

Whether this function is public (requires –preview modules)

§is_unchecked: bool

Whether this function is marked unchecked (can only be called from checked blocks)

§name: Spur
§params_start: u32

Index into extra data where params start

§params_len: u32

Number of parameters

§return_type: Spur
§body: InstRef
§has_self: bool

Whether this function/method takes self as a receiver. Only true for methods in impl blocks that have a self parameter. Used by sema to know to add the implicit self parameter.

§

ConstDecl

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

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§is_pub: bool

Whether this constant is public (requires –preview modules)

§name: Spur

Constant name

§ty: Option<Spur>

Optional type annotation (interned string, None if inferred)

§init: InstRef

Initializer expression

§

Call

Function call Args are stored in the extra array using add_call_args/get_call_args.

Fields

§name: Spur

Function name

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

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: Spur

Intrinsic name (without @)

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

TypeIntrinsic

Intrinsic call with a type argument (e.g., @size_of, @align_of)

Fields

§name: Spur

Intrinsic name (without @)

§type_arg: Spur

Type argument (as an interned string, e.g., “i32”, “Point”, “[i32; 4]”)

§

ParamRef

Reference to a function parameter

Fields

§index: u32

Parameter index (0-based)

§name: Spur

Parameter name (for error messages)

§

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

§extra_start: u32

Index into extra data where instruction refs start

§len: u32

Number of instructions in the block

§

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

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§name: Option<Spur>

Variable name (None for wildcard _ pattern that discards the value)

§is_mut: bool

Whether the variable is mutable

§ty: Option<Spur>

Optional type annotation

§init: InstRef

Initial value instruction

§

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: Spur

Struct type name

§fields_start: u32

Index into extra data where field data starts

§fields_len: u32

Number of fields

§init: InstRef

Initializer expression

§

VarRef

Variable reference: reads the value of a variable

Fields

§name: Spur

Variable name

§

Assign

Assignment: stores a value into a mutable variable

Fields

§name: Spur

Variable name

§value: InstRef

Value to store

§

StructDecl

Struct type declaration Directives, fields, and methods are stored in the extra array.

Fields

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§is_pub: bool

Whether this struct is public (requires –preview modules)

§is_linear: bool

Whether this struct is a linear type (must be consumed)

§name: Spur

Struct name

§fields_start: u32

Index into extra data where fields start

§fields_len: u32

Number of fields

§methods_start: u32

Index into extra data where method refs start

§methods_len: u32

Number of methods

§

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: Spur

Struct type name

§fields_start: u32

Index into extra data where fields start

§fields_len: u32

Number of fields

§

FieldGet

Field access: reads a field from a struct

Fields

§base: InstRef

Base struct value

§field: Spur

Field name

§

FieldSet

Field assignment: writes a value to a struct field

Fields

§base: InstRef

Base struct value

§field: Spur

Field name

§value: InstRef

Value to store

§

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

§is_pub: bool

Whether this enum is public (requires –preview modules)

§name: Spur

Enum name

§variants_start: u32

Index into extra data where variants start

§variants_len: u32

Number of variants

§

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: Spur

Enum type name

§variant: Spur

Variant name

§

EnumStructVariant

Enum struct variant construction: Enum::Variant { field: value, ... } Fields are stored in the extra array using add_field_inits/get_field_inits.

Fields

§module: Option<InstRef>

Optional module reference (for qualified paths)

§type_name: Spur

Enum type name

§variant: Spur

Variant name

§fields_start: u32

Start of field initializers in extra array

§fields_len: u32

Number of field initializers

§

ArrayInit

Array literal: creates a new array from element values Elements are stored in the extra array using add_inst_refs/get_inst_refs.

Fields

§elems_start: u32

Index into extra data where elements start

§elems_len: u32

Number of elements

§

IndexGet

Array index read: reads an element from an array

Fields

§base: InstRef

Base array value

§index: InstRef

Index expression

§

IndexSet

Array index write: writes a value to an array element

Fields

§base: InstRef

Base array value (must be a VarRef to a mutable variable)

§index: InstRef

Index expression

§value: InstRef

Value to store

§

MethodCall

Method call: receiver.method(args) Args are stored in the extra array using add_call_args/get_call_args.

Fields

§receiver: InstRef

Receiver expression (the struct value)

§method: Spur

Method name

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

AssocFnCall

Associated function call: Type::function(args) Args are stored in the extra array using add_call_args/get_call_args.

Fields

§type_name: Spur

Type name (e.g., Point)

§function: Spur

Function name (e.g., origin)

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

DropFnDecl

User-defined destructor declaration: drop fn TypeName(self) { … }

Fields

§type_name: Spur

The struct type this destructor is for

§body: InstRef

Destructor body instruction ref

§

Comptime

Comptime block expression: comptime { expr } The inner expression must be evaluable at compile time.

Fields

§expr: InstRef

The expression to evaluate 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: Spur

The loop variable name

§iterable: InstRef

The iterable expression (must be comptime-evaluable, e.g. @typeInfo fields)

§body: InstRef

The loop body (will be unrolled at compile time)

§

Checked

Checked block expression: checked { expr } Unchecked operations (raw pointer manipulation, calling unchecked functions) are only allowed inside checked blocks.

Fields

§expr: InstRef

The expression inside the checked block

§

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: Spur

The 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

§fields_start: u32

Index into extra data where fields start

§fields_len: u32

Number of fields

§methods_start: u32

Index into extra data where method InstRefs start

§methods_len: u32

Number of methods (InstRefs to FnDecl instructions)

§

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.

Fields

§variants_start: u32

Index into extra data where variants start

§variants_len: u32

Number of variants

§methods_start: u32

Index into extra data where method InstRefs start

§methods_len: u32

Number of methods (InstRefs to FnDecl instructions)

Trait Implementations§

Source§

impl Clone for InstData

Source§

fn clone(&self) -> InstData

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 InstData

Source§

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

Formats the value using the given formatter. Read more

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.

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].
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, 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> OrderedSeq<'_, T> for T
where T: Clone,