Skip to main content

TypedStmtKind

Enum TypedStmtKind 

Source
pub enum TypedStmtKind {
Show 21 variants Let { name: Ident, ty: Type, value: ExprId, boxed: bool, doc: Option<DocComment>, }, ReboxLocal { ident: Ident, ty: Type, }, Const { name: Ident, ty: Type, value: ExprId, doc: Option<DocComment>, }, If { condition: ExprId, then_block: StmtId, else_block: Option<StmtId>, }, While { condition: ExprId, body: StmtId, }, For { init: Option<StmtId>, condition: Option<ExprId>, update: Option<StmtId>, body: StmtId, }, ForOf { binding_kind: BindingKind, name: Ident, element_ty: Type, iter: ExprId, body: StmtId, kind: ForOfKind, }, DoWhile { body: StmtId, condition: ExprId, }, Switch { discriminant: ExprId, discriminant_ty: Type, cases: Vec<TypedSwitchCase>, default: Option<StmtId>, }, Break, Continue, Return(Option<ExprId>), Throw { value: ExprId, }, Try { body: StmtId, catches: Vec<TypedCatchClause>, finally: Option<StmtId>, }, Expr(ExprId), Block(Vec<StmtId>), AssignLocal { ident: Ident, target_ty: Type, value: ExprId, boxed: bool, narrowed_shadow_ty: Option<Type>, }, AssignGlobal { ident: Ident, mangled: MangledName, target_ty: Type, value: ExprId, }, AssignField { receiver: ExprId, name: Ident, value: ExprId, }, AssignIndex { receiver: ExprId, index: ExprId, value: ExprId, elem_ty: Type, }, NarrowRegion { path: ReferencePath, source: ExprId, binding: Ident, cast_info: CastInfo, body: StmtId, },
}

Variants§

§

Let

Function-local only; top-level let is in TypedAst::globals. ty is the annotation when present, else the inferred type — annotation wins on mismatch.

Fields

§name: Ident
§ty: Type
§value: ExprId
§boxed: bool
§

ReboxLocal

Replace the box in ident’s slot with a fresh one holding the same value, so closures created from here on capture a cell nothing before them shares.

Only the for lowering emits this, for the per-iteration binding a let head has in JS (ECMA-262 §14.7.4.4 CreatePerIterationEnvironment): each pass gets its own copy, which is why for (let i …) fns.push(() => i) yields 0,1,2 rather than three views of one slot. ident must name a boxed binding — an unboxed one is captured by value, so there is nothing to separate.

Fields

§ident: Ident
§ty: Type
§

Const

Captured const bindings are copied into the closure env (no boxed field). Function-local only — see Let.

Fields

§name: Ident
§ty: Type
§value: ExprId
§

If

Fields

§condition: ExprId
§then_block: StmtId
§else_block: Option<StmtId>
§

While

Fields

§condition: ExprId
§body: StmtId
§

For

Pre-desugar; codegen never sees this variant.

Fields

§condition: Option<ExprId>
§update: Option<StmtId>
§body: StmtId
§

ForOf

Pre-desugar; codegen never sees this variant. kind lets desugar dispatch without re-running assignability.

Fields

§binding_kind: BindingKind
§name: Ident
§element_ty: Type
§iter: ExprId
§body: StmtId
§

DoWhile

Pre-desugar; lowers to a while-true whose head tests cond on every pass but the first, so a continue still reaches the test.

Fields

§body: StmtId
§condition: ExprId
§

Switch

Not lowered to if/else — first-class through desugar and codegen. discriminant_ty drives dispatch strategy. Case bodies are wrapped in NarrowRegion by the inferer for discriminated-union narrowing.

Fields

§discriminant: ExprId
§discriminant_ty: Type
§default: Option<StmtId>
§

Break

§

Continue

Desugar injects the update step before the jump in for/for-of. A switch frame on the loop-contexts stack is skipped so continue inside switch reaches the enclosing loop.

§

Return(Option<ExprId>)

§

Throw

throw <expr>. Value must be Error; diverges in control-flow analysis.

Fields

§value: ExprId
§

Try

catches dispatch in declaration order on the thrown value’s nominal class; an unmatched error re-raises. Codegen duplicates finally on normal/caught/uncaught paths.

Fields

§body: StmtId
§finally: Option<StmtId>
§

Expr(ExprId)

§

Block(Vec<StmtId>)

§

AssignLocal

Function-scope binding assignment. target_ty is the slot’s declared type; codegen coerces primitives into ref-typed slots (e.g. number | null boxes f64).

Fields

§ident: Ident
§target_ty: Type
§value: ExprId
§boxed: bool
§narrowed_shadow_ty: Option<Type>

When set, codegen materializes a shadow Wasm local of this narrowed type alongside the slot write. Subsequent LocalNarrowRef reads resolve to the shadow; it disappears at block exit.

§

AssignGlobal

const and function targets are rejected. target_ty mirrors AssignLocal.target_ty for codegen coercion.

Fields

§ident: Ident
§mangled: MangledName
§target_ty: Type
§value: ExprId
§

AssignField

Fields

§receiver: ExprId
§name: Ident
§value: ExprId
§

AssignIndex

elem_ty is carried so codegen picks the boxing path without re-walking the receiver’s Type.

Fields

§receiver: ExprId
§index: ExprId
§value: ExprId
§elem_ty: Type
§

NarrowRegion

Wraps then/else blocks and switch case bodies. path is for diagnostics; codegen consults only source, cast_info, binding, and body.

Fields

§source: ExprId
§binding: Ident
§cast_info: CastInfo
§body: StmtId

Trait Implementations§

Source§

impl Clone for TypedStmtKind

Source§

fn clone(&self) -> Self

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 TypedStmtKind

Source§

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

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

impl PartialEq for TypedStmtKind

Source§

fn eq(&self, other: &Self) -> 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 TypedStmtKind

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more