Skip to main content

TypeEnvironment

Struct TypeEnvironment 

Source
pub struct TypeEnvironment { /* private fields */ }
Expand description

A type environment that maps symbol refs to their resolved types. This is populated before type checking and passed to the SubtypeChecker.

Implementations§

Source§

impl TypeEnvironment

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, symbol: SymbolRef, type_id: TypeId)

Register a symbol’s resolved type.

Source

pub fn set_boxed_type(&mut self, kind: IntrinsicKind, type_id: TypeId)

Register a boxed type for a primitive (Rule #33).

Source

pub fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>

Get the boxed type for a primitive.

Source

pub fn register_boxed_def_id(&mut self, kind: IntrinsicKind, def_id: DefId)

Register a DefId as belonging to a boxed type.

Source

pub fn is_boxed_def_id(&self, def_id: DefId, kind: IntrinsicKind) -> bool

Check if a DefId corresponds to a boxed type of the given kind.

Source

pub fn is_boxed_type_id(&self, type_id: TypeId, kind: IntrinsicKind) -> bool

Check if a TypeId is any known resolved form of a boxed type.

Source

pub fn set_array_base_type( &mut self, type_id: TypeId, type_params: Vec<TypeParamInfo>, )

Register the Array interface type from lib.d.ts.

Source

pub const fn get_array_base_type(&self) -> Option<TypeId>

Get the Array interface type.

Source

pub fn get_array_base_type_params(&self) -> &[TypeParamInfo]

Get the type parameters for the Array interface.

Source

pub fn insert_with_params( &mut self, symbol: SymbolRef, type_id: TypeId, params: Vec<TypeParamInfo>, )

Register a symbol’s resolved type with type parameters.

Source

pub fn get(&self, symbol: SymbolRef) -> Option<TypeId>

Get a symbol’s resolved type.

Source

pub fn get_params(&self, symbol: SymbolRef) -> Option<&Vec<TypeParamInfo>>

Get a symbol’s type parameters.

Source

pub fn contains(&self, symbol: SymbolRef) -> bool

Check if the environment contains a symbol.

Source

pub fn len(&self) -> usize

Number of resolved types.

Source

pub fn is_empty(&self) -> bool

Check if empty.

Source

pub fn insert_def(&mut self, def_id: DefId, type_id: TypeId)

Register a DefId’s resolved type.

Source

pub fn insert_class_instance_type( &mut self, def_id: DefId, instance_type: TypeId, )

Register a class DefId’s instance type.

Source

pub fn insert_def_with_params( &mut self, def_id: DefId, type_id: TypeId, params: Vec<TypeParamInfo>, )

Register a DefId’s resolved type with type parameters.

Source

pub fn get_def(&self, def_id: DefId) -> Option<TypeId>

Get a DefId’s resolved type.

Source

pub fn get_def_params(&self, def_id: DefId) -> Option<&Vec<TypeParamInfo>>

Get a DefId’s type parameters.

Source

pub fn contains_def(&self, def_id: DefId) -> bool

Check if the environment contains a DefId.

Source

pub fn merge_defs_into(&self, target: &mut Self)

Merge def entries (types and type params) from this environment into another.

Source

pub fn insert_def_kind(&mut self, def_id: DefId, kind: DefKind)

Register a DefId’s DefKind.

Source

pub fn get_def_kind(&self, def_id: DefId) -> Option<DefKind>

Get a DefId’s DefKind.

Source

pub fn register_def_symbol_mapping(&mut self, def_id: DefId, sym_id: SymbolId)

Register a mapping from DefId to SymbolId for InheritanceGraph lookups.

Also registers the reverse mapping (SymbolId -> DefId).

Source

pub fn register_numeric_enum(&mut self, def_id: DefId)

Register a DefId as a numeric enum.

Source

pub fn is_numeric_enum(&self, def_id: DefId) -> bool

Check if a DefId is a numeric enum.

Source

pub fn register_enum_parent( &mut self, member_def_id: DefId, parent_def_id: DefId, )

Register an enum member’s parent enum DefId.

Source

pub fn get_enum_parent(&self, member_def_id: DefId) -> Option<DefId>

Get the parent enum DefId for an enum member DefId.

Trait Implementations§

Source§

impl Clone for TypeEnvironment

Source§

fn clone(&self) -> TypeEnvironment

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 TypeEnvironment

Source§

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

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

impl Default for TypeEnvironment

Source§

fn default() -> TypeEnvironment

Returns the “default value” for a type. Read more
Source§

impl TypeResolver for TypeEnvironment

Source§

fn resolve_ref( &self, symbol: SymbolRef, _interner: &dyn TypeDatabase, ) -> Option<TypeId>

Resolve a symbol reference to its structural type. Returns None if the symbol cannot be resolved. Read more
Source§

fn resolve_lazy( &self, def_id: DefId, _interner: &dyn TypeDatabase, ) -> Option<TypeId>

Resolve a DefId reference to its structural type. Read more
Source§

fn get_type_params(&self, symbol: SymbolRef) -> Option<Vec<TypeParamInfo>>

Get type parameters for a symbol (for generic type aliases/interfaces). Returns None by default; implementations can override to support Application type expansion.
Source§

fn get_lazy_type_params(&self, def_id: DefId) -> Option<Vec<TypeParamInfo>>

Get type parameters for a DefId (for generic type aliases/interfaces). Read more
Source§

fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>

Get the boxed interface type for a primitive intrinsic (Rule #33). For example, IntrinsicKind::Number -> TypeId of the Number interface. This enables primitives to be subtypes of their boxed interfaces.
Source§

fn is_boxed_def_id(&self, def_id: DefId, kind: IntrinsicKind) -> bool

Check if a DefId corresponds to a boxed type for the given intrinsic kind.
Source§

fn is_boxed_type_id(&self, type_id: TypeId, kind: IntrinsicKind) -> bool

Check if a TypeId is any known resolved form of a boxed type. Read more
Source§

fn get_array_base_type(&self) -> Option<TypeId>

Get the Array interface type from lib.d.ts.
Source§

fn get_array_base_type_params(&self) -> &[TypeParamInfo]

Get the type parameters for the Array interface.
Source§

fn def_to_symbol_id(&self, def_id: DefId) -> Option<SymbolId>

Get the SymbolId for a DefId (bridge for InheritanceGraph). Read more
Source§

fn symbol_to_def_id(&self, symbol: SymbolRef) -> Option<DefId>

Get the DefId for a SymbolRef (Ref -> Lazy migration). Read more
Source§

fn get_def_kind(&self, def_id: DefId) -> Option<DefKind>

Get the DefKind for a DefId (Task #32: Graph Isomorphism). Read more
Source§

fn is_numeric_enum(&self, def_id: DefId) -> bool

Check if a DefId corresponds to a numeric enum (not a string enum). Read more
Source§

fn get_enum_parent_def_id(&self, member_def_id: DefId) -> Option<DefId>

Get the parent Enum’s DefId for an Enum Member’s DefId. Read more
Source§

fn is_user_enum_def(&self, _def_id: DefId) -> bool

Check if a DefId represents a user-defined enum (not an intrinsic type).
Source§

fn resolve_symbol_ref( &self, symbol: SymbolRef, interner: &dyn TypeDatabase, ) -> Option<TypeId>

Resolve a symbol reference to a structural type, preferring DefId-based lazy paths. Read more
Source§

fn get_lazy_export(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>

Get an export from a namespace/module by name. Read more
Source§

fn get_lazy_enum_member(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>

Get enum member type by name from an enum DefId. Read more
Source§

fn is_enum_type(&self, _type_id: TypeId, _interner: &dyn TypeDatabase) -> bool

Check if a TypeId represents a full Enum type (not a specific member).
Source§

fn get_base_type( &self, _type_id: TypeId, _interner: &dyn TypeDatabase, ) -> Option<TypeId>

Get the base class type for a class/interface type. Read more
Source§

fn get_type_param_variance(&self, _def_id: DefId) -> Option<Arc<[Variance]>>

Get the variance mask for type parameters of a generic type (Task #41). 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> 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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
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