Skip to main content

TypedAst

Struct TypedAst 

Source
pub struct TypedAst {
Show 29 fields pub parameter_default_prologues: BTreeMap<StmtId, usize>, pub closure_this: BTreeMap<ExprId, Type>, pub closure_names: BTreeMap<ExprId, Ident>, pub nested_function_names: BTreeMap<ExprId, Ident>, pub placeholder_closures: BTreeSet<ExprId>, pub authored_arguments: BTreeMap<(u32, u32, u32), Vec<ExprId>>, pub authored_parameter_types: BTreeMap<(u32, u32, u32), Type>, pub parameter_inputs: BTreeSet<ExprId>, pub parameter_initializations: BTreeSet<StmtId>, pub runtime_source_types: BTreeMap<ExprId, Type>, pub runtime_chain_types: BTreeMap<ExprId, Vec<Type>>, pub spread_mask_fields: BTreeMap<ExprId, BTreeMap<String, Type>>, pub spread_omitted_fields: BTreeMap<ExprId, BTreeSet<String>>, pub exhaustive_switches: BTreeSet<ExprId>, pub package_name: String, pub globals: Vec<TypedGlobal>, pub rebindable_globals: BTreeMap<MangledName, String>, pub functions: Vec<TypedFunction>, pub top_level_statements: Vec<StmtId>, pub class_declaration_points: BTreeMap<MangledName, usize>, pub types: Vec<TypedTypeDecl>, pub shapes: Vec<Shape>, pub exports: Vec<ExportEntry>, pub imported_packages: BTreeSet<String>, pub runtime_type_tests: BTreeMap<Type, FieldNarrowingTest>, pub runtime_class_fields: BTreeMap<Type, Type>, pub runtime_class_parameters: BTreeMap<MangledName, Vec<String>>, pub runtime_class_contexts: BTreeMap<Type, Vec<InstanceTypeContext>>, pub runtime_field_guards: BTreeMap<Type, Vec<InstantiatedFieldGuard>>, /* private fields */
}

Fields§

§parameter_default_prologues: BTreeMap<StmtId, usize>

Number of parameter-initialization statements before a wrapped body.

§closure_this: BTreeMap<ExprId, Type>

Receiver types for ordinary function expressions; arrows capture their receiver.

§closure_names: BTreeMap<ExprId, Ident>

Named function-expression bindings, scoped to their closure body.

§nested_function_names: BTreeMap<ExprId, Ident>

The closures nested function declarations become, by declared name, so a diagnostic about one can name it as the function it is.

§placeholder_closures: BTreeSet<ExprId>

Closures with empty bodies that hold a nested function’s binding until its real closure is assigned. The typechecker rejects every use before then, so they are never called: a non-void one traps if it is.

§authored_arguments: BTreeMap<(u32, u32, u32), Vec<ExprId>>

Arguments before omitted defaults and rest packing, keyed by call span.

§authored_parameter_types: BTreeMap<(u32, u32, u32), Type>

Parameter declaration types before optional/default ABI input widening.

§parameter_inputs: BTreeSet<ExprId>

Synthetic reads of incoming arguments before a parameter becomes initialized.

§parameter_initializations: BTreeSet<StmtId>

Callee prologue statements that initialize parameters and pattern bindings.

§runtime_source_types: BTreeMap<ExprId, Type>

Authored expression types retained by runtime-value lowering for member selection. Physical slot types live on the lowered expressions.

§runtime_chain_types: BTreeMap<ExprId, Vec<Type>>§spread_mask_fields: BTreeMap<ExprId, BTreeMap<String, Type>>

For each spread source read by name, the fields its value is checked against: every field one of its object types names, with the union of the types they give it, an index signature’s value type included.

§spread_omitted_fields: BTreeMap<ExprId, BTreeSet<String>>

For each spread source of an object rest, the names the rest leaves out whatever their value.

§exhaustive_switches: BTreeSet<ExprId>

The discriminants of the switches without a default whose cases the typechecker found match every value the discriminant can hold.

§package_name: String

Module name used for mangling. Defaults to USER_PACKAGE ("main").

§globals: Vec<TypedGlobal>

Slot definitions only; initializers are AssignGlobal in top_level_statements.

§rebindable_globals: BTreeMap<MangledName, String>

The globals code can rebind after the package loads that this package declares or imports, each with how the source names it: a module let, its own or one another package exports, and a static field not declared readonly, as Class.field. Every static field is a GlobalKind::Const global, so globals alone cannot tell.

§functions: Vec<TypedFunction>

Top-level function declarations. Hoisted — codegen doesn’t depend on source order.

§top_level_statements: Vec<StmtId>

Source-order _start body — currently one AssignGlobal per global initializer.

§class_declaration_points: BTreeMap<MangledName, usize>

Where each top-level class is declared: the index into top_level_statements of the first statement that runs after it.

§types: Vec<TypedTypeDecl>

Type declarations (interface, enum) — no Wasm representation, no body. Stored here so post-inference passes see member spans/types without re-exposing the inferer’s TypeNamespace.

§shapes: Vec<Shape>

Distinct anonymous shapes (Object, Array, Union) reachable from the module. Built at end of inference; consumers read this instead of re-walking the AST.

§exports: Vec<ExportEntry>

Public surface: one entry per export-marked declaration. Single source of truth for visibility — TypedFunction/TypedGlobal carry no is_exported flag. Built but not yet consumed for surface projection in single-file mode.

§imported_packages: BTreeSet<String>

External package names that were resolved from explicit imports in this module. This is deliberately package-level, not symbol-level: embedders use it to install only the package modules the typed program imports.

§runtime_type_tests: BTreeMap<Type, FieldNarrowingTest>

Concrete runtime validators resolved while inference still has access to interface declarations and generic substitutions. Codegen consults this for narrowed reads instead of re-deriving type structure.

§runtime_class_fields: BTreeMap<Type, Type>

Substituted data fields for generic-class runtime validation.

§runtime_class_parameters: BTreeMap<MangledName, Vec<String>>§runtime_class_contexts: BTreeMap<Type, Vec<InstanceTypeContext>>§runtime_field_guards: BTreeMap<Type, Vec<InstantiatedFieldGuard>>

Implementations§

Source§

impl TypedAst

Source

pub fn new() -> Self

Source

pub fn with_package(package_name: impl Into<String>) -> Self

Source

pub fn record_authored_arguments(&mut self, span: Span, args: Vec<ExprId>)

Source

pub fn authored_call_arguments(&self, span: Span) -> Option<&Vec<ExprId>>

Source

pub fn try_push_expr(&mut self, expr: TypedExpr) -> Result<ExprId, ArenaError>

Checked allocation; failure leaves the arena unchanged.

Source

pub fn try_push_stmt(&mut self, stmt: TypedStmt) -> Result<StmtId, ArenaError>

Checked allocation; failure leaves the arena unchanged.

Source

pub fn try_expr(&self, id: ExprId) -> Result<&TypedExpr, ArenaError>

Source

pub fn try_stmt(&self, id: StmtId) -> Result<&TypedStmt, ArenaError>

Source

pub fn try_expr_mut(&mut self, id: ExprId) -> Result<&mut TypedExpr, ArenaError>

Source

pub fn try_stmt_mut(&mut self, id: StmtId) -> Result<&mut TypedStmt, ArenaError>

Source

pub fn expr_ids( &self, ) -> Result<impl DoubleEndedIterator<Item = ExprId> + use<>, ArenaError>

Snapshot of allocated expression IDs, usable while appending new nodes.

Source

pub fn stmt_ids( &self, ) -> Result<impl DoubleEndedIterator<Item = StmtId> + use<>, ArenaError>

Snapshot of allocated statement IDs, usable while appending new nodes.

Source

pub fn class_body_roots(&self) -> Vec<StmtId>

Body StmtIds of every class constructor + method — additional codegen roots alongside functions (the string/bigint/closure/box collection passes must walk these too).

Source

pub fn class_field_initializers(&self) -> Vec<ExprId>

Field-initializer expressions across all classes — expr roots that live outside any statement body, so analysis/erasure passes must visit them too.

Source

pub fn source_type(&self, id: ExprId) -> Result<&Type, ArenaError>

Source

pub fn exprs_len(&self) -> usize

Used by post-inference passes to iterate just-pushed IDs (e.g. GenericParam erasure).

Source

pub fn stmts_len(&self) -> usize

Source

pub fn is_effect_free(&self, id: ExprId) -> Result<bool, ArenaError>

Whether evaluating id can be skipped without changing what the program does. Deliberately a short whitelist of leaves: everything else — a call, a field read that may hit an accessor, an operator that may throw — says false, so a caller that folds an expression’s value away and relies on this to decide whether to keep the computation errs toward keeping it.

Trait Implementations§

Source§

impl Clone for TypedAst

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 TypedAst

Source§

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

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

impl Default for TypedAst

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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