Skip to main content

Stmt

Enum Stmt 

Source
pub enum Stmt {
Show 26 variants ConstInt(Temp, i64), ConstFloat(Temp, f64), ConstBool(Temp, bool), ConstStr(Temp, String), ConstUnit(Temp), Copy { dst: Temp, src: Temp, }, Bin { dst: Temp, op: BinOp, class: OperandClass, lhs: Temp, rhs: Temp, }, Neg { dst: Temp, class: OperandClass, src: Temp, }, Not { dst: Temp, src: Temp, }, BitNot { dst: Temp, src: Temp, }, Call { dst: Option<Temp>, callee: String, args: Vec<Temp>, }, CallIndirect { dst: Option<Temp>, callee: Temp, params: Vec<MirTy>, ret: MirTy, args: Vec<Temp>, }, Await { dst: Option<Temp>, future: Temp, }, CallRuntime { dst: Option<Temp>, func: RtFunc, args: Vec<Temp>, }, MakeClosure { dst: Temp, code: String, captures: Vec<(Temp, MirTy)>, }, MakeSum { dst: Temp, tag: u32, fields: Vec<(Temp, MirTy)>, }, SumTag { dst: Temp, sum: Temp, }, SumField { dst: Temp, sum: Temp, index: u32, ty: MirTy, }, MakeRecord { dst: Temp, fields: Vec<(Temp, MirTy)>, }, RecordField { dst: Temp, record: Temp, index: u32, ty: MirTy, }, SetField { record: Temp, index: u32, value: Temp, ty: MirTy, }, MakeArray { dst: Temp, elems: Vec<(Temp, MirTy)>, }, ArrayAlloc { dst: Temp, len: Temp, }, ArrayLen { dst: Temp, arr: Temp, }, ArrayGet { dst: Temp, arr: Temp, index: Temp, ty: MirTy, }, ArraySet { arr: Temp, index: Temp, value: Temp, ty: MirTy, },
}
Expand description

A single 3-address statement.

Variants§

§

ConstInt(Temp, i64)

§

ConstFloat(Temp, f64)

§

ConstBool(Temp, bool)

§

ConstStr(Temp, String)

Interned string literal; codegen emits it as module data.

§

ConstUnit(Temp)

§

Copy

Fields

§dst: Temp
§src: Temp
§

Bin

Fields

§dst: Temp
§lhs: Temp
§rhs: Temp
§

Neg

Fields

§dst: Temp
§src: Temp
§

Not

Boolean not.

Fields

§dst: Temp
§src: Temp
§

BitNot

Bitwise not (I64).

Fields

§dst: Temp
§src: Temp
§

Call

Direct call to another Nova function by mangled name.

Fields

§callee: String
§args: Vec<Temp>
§

CallIndirect

Indirect call through a function value (fat pointer). callee is a { code_ptr, env_ptr } block; codegen loads both and calls code_ptr(env_ptr, args...). params are the real parameter classes (excluding the leading env).

Fields

§callee: Temp
§params: Vec<MirTy>
§ret: MirTy
§args: Vec<Temp>
§

Await

A suspend point — future.await — before the async state-machine transform has turned it into control flow.

No statement reaching a codegen backend is this one. It is a marker that async_lower’s block split consumes, replacing it with the sequence that actually performs an await: poll future through its own fat pointer, return POLL_PENDING if the answer is pending, and otherwise copy the awaited value out of the inner state object’s output slot into dst’s slot. Every part of that sequence addresses the state object of the function containing the await, which does not exist until the transform builds it — so the suspend cannot be lowered into control flow where it is parsed without inventing that layout twice. Both backends reject this variant rather than emitting anything for it.

future holds a { poll_code, state } two-word future value, the same fat-pointer shape MakeClosure builds. dst is None exactly when the awaited output is unit, matching Call’s convention for a call that produces no value.

Fields

§future: Temp
§

CallRuntime

Call into the Nova runtime.

Fields

§func: RtFunc
§args: Vec<Temp>
§

MakeClosure

Build a function value: a 2-word fat pointer { code_ptr, env_ptr }. code is the mangled callee whose address is code_ptr; captures are stored into a freshly allocated environment (empty → null env).

Fields

§dst: Temp
§code: String
§captures: Vec<(Temp, MirTy)>
§

MakeSum

Allocate and initialize a sum value: { tag, fields... }.

Fields

§dst: Temp
§tag: u32
§fields: Vec<(Temp, MirTy)>
§

SumTag

Load the tag of a sum value.

Fields

§dst: Temp
§sum: Temp
§

SumField

Load payload field index of a sum value.

Fields

§dst: Temp
§sum: Temp
§index: u32
§

MakeRecord

Allocate and initialize a record value { fields... } (no tag).

Fields

§dst: Temp
§fields: Vec<(Temp, MirTy)>
§

RecordField

Load field index of a record value.

Fields

§dst: Temp
§record: Temp
§index: u32
§

SetField

Store field index of a record. Mirrors RecordField’s 8 * index offset, so reads and writes stay in the same layout.

Fields

§record: Temp
§index: u32
§value: Temp
§

MakeArray

Allocate and initialize an array { len, elems... }.

Fields

§dst: Temp
§elems: Vec<(Temp, MirTy)>
§

ArrayAlloc

Allocate an array of len elements: 8 + 8*len zeroed bytes with len stored at offset 0. Elements are left zeroed — the lowering fills them with its own loop (see lower_array_repeat), so neither backend needs a loop emitter.

len must be in 0..=MAX_ARRAY_LEN; the lowering guarantees that by emitting guards that abort first. Both bounds are memory-safety requirements, because both backends compute the size as 8*len + 8 with wrapping arithmetic:

  • A small negative len is harmless on its own — gc::alloc clamps every request with size.max(8), so 8 + 8*(-1) = 0 still yields a block the 8-byte length store fits in — but storing a negative length would leave an array whose every access fails, and a large-magnitude negative len overflows the 8 * len multiplication into a wild size.
  • A len above MAX_ARRAY_LEN wraps 8*len + 8 back to a negative size (at len = 2^60 it is exactly i64::MIN + 8), which the same size.max(8) clamp turns into an 8-byte block. The huge length is then stored into that block’s header and the fill loop — which carries no bounds check by design — writes far past its end.

Aborting up front reports the mistake where it was made instead.

Fields

§dst: Temp
§len: Temp
§

ArrayLen

Load the length (element count) of an array.

Fields

§dst: Temp
§arr: Temp
§

ArrayGet

Load arr[index] (dynamic index; caller has bounds-checked).

Fields

§dst: Temp
§arr: Temp
§index: Temp
§

ArraySet

Store arr[index] = value (dynamic index; caller has bounds-checked).

Fields

§arr: Temp
§index: Temp
§value: Temp

Trait Implementations§

Source§

impl Debug for Stmt

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Stmt

§

impl RefUnwindSafe for Stmt

§

impl Send for Stmt

§

impl Sync for Stmt

§

impl Unpin for Stmt

§

impl UnsafeUnpin for Stmt

§

impl UnwindSafe for Stmt

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> 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, 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, !>

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.