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
impl TypeEnvironment
pub fn new() -> Self
Sourcepub fn insert(&mut self, symbol: SymbolRef, type_id: TypeId)
pub fn insert(&mut self, symbol: SymbolRef, type_id: TypeId)
Register a symbol’s resolved type.
Sourcepub fn set_boxed_type(&mut self, kind: IntrinsicKind, type_id: TypeId)
pub fn set_boxed_type(&mut self, kind: IntrinsicKind, type_id: TypeId)
Register a boxed type for a primitive (Rule #33).
Sourcepub fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>
pub fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>
Get the boxed type for a primitive.
Sourcepub fn register_boxed_def_id(&mut self, kind: IntrinsicKind, def_id: DefId)
pub fn register_boxed_def_id(&mut self, kind: IntrinsicKind, def_id: DefId)
Register a DefId as belonging to a boxed type.
Sourcepub fn is_boxed_def_id(&self, def_id: DefId, kind: IntrinsicKind) -> bool
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.
Sourcepub fn is_boxed_type_id(&self, type_id: TypeId, kind: IntrinsicKind) -> bool
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.
Sourcepub fn set_array_base_type(
&mut self,
type_id: TypeId,
type_params: Vec<TypeParamInfo>,
)
pub fn set_array_base_type( &mut self, type_id: TypeId, type_params: Vec<TypeParamInfo>, )
Register the Array
Sourcepub const fn get_array_base_type(&self) -> Option<TypeId>
pub const fn get_array_base_type(&self) -> Option<TypeId>
Get the Array
Sourcepub fn get_array_base_type_params(&self) -> &[TypeParamInfo]
pub fn get_array_base_type_params(&self) -> &[TypeParamInfo]
Get the type parameters for the Array
Sourcepub fn insert_with_params(
&mut self,
symbol: SymbolRef,
type_id: TypeId,
params: Vec<TypeParamInfo>,
)
pub fn insert_with_params( &mut self, symbol: SymbolRef, type_id: TypeId, params: Vec<TypeParamInfo>, )
Register a symbol’s resolved type with type parameters.
Sourcepub fn get_params(&self, symbol: SymbolRef) -> Option<&Vec<TypeParamInfo>>
pub fn get_params(&self, symbol: SymbolRef) -> Option<&Vec<TypeParamInfo>>
Get a symbol’s type parameters.
Sourcepub fn insert_def(&mut self, def_id: DefId, type_id: TypeId)
pub fn insert_def(&mut self, def_id: DefId, type_id: TypeId)
Register a DefId’s resolved type.
Sourcepub fn insert_class_instance_type(
&mut self,
def_id: DefId,
instance_type: TypeId,
)
pub fn insert_class_instance_type( &mut self, def_id: DefId, instance_type: TypeId, )
Register a class DefId’s instance type.
Sourcepub fn insert_def_with_params(
&mut self,
def_id: DefId,
type_id: TypeId,
params: Vec<TypeParamInfo>,
)
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.
Sourcepub fn get_def_params(&self, def_id: DefId) -> Option<&Vec<TypeParamInfo>>
pub fn get_def_params(&self, def_id: DefId) -> Option<&Vec<TypeParamInfo>>
Get a DefId’s type parameters.
Sourcepub fn contains_def(&self, def_id: DefId) -> bool
pub fn contains_def(&self, def_id: DefId) -> bool
Check if the environment contains a DefId.
Sourcepub fn merge_defs_into(&self, target: &mut Self)
pub fn merge_defs_into(&self, target: &mut Self)
Merge def entries (types and type params) from this environment into another.
Sourcepub fn insert_def_kind(&mut self, def_id: DefId, kind: DefKind)
pub fn insert_def_kind(&mut self, def_id: DefId, kind: DefKind)
Register a DefId’s DefKind.
Sourcepub fn get_def_kind(&self, def_id: DefId) -> Option<DefKind>
pub fn get_def_kind(&self, def_id: DefId) -> Option<DefKind>
Get a DefId’s DefKind.
Sourcepub fn register_def_symbol_mapping(&mut self, def_id: DefId, sym_id: SymbolId)
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).
Sourcepub fn register_numeric_enum(&mut self, def_id: DefId)
pub fn register_numeric_enum(&mut self, def_id: DefId)
Register a DefId as a numeric enum.
Sourcepub fn is_numeric_enum(&self, def_id: DefId) -> bool
pub fn is_numeric_enum(&self, def_id: DefId) -> bool
Check if a DefId is a numeric enum.
Sourcepub fn register_enum_parent(
&mut self,
member_def_id: DefId,
parent_def_id: DefId,
)
pub fn register_enum_parent( &mut self, member_def_id: DefId, parent_def_id: DefId, )
Register an enum member’s parent enum DefId.
Sourcepub fn get_enum_parent(&self, member_def_id: DefId) -> Option<DefId>
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
impl Clone for TypeEnvironment
Source§fn clone(&self) -> TypeEnvironment
fn clone(&self) -> TypeEnvironment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TypeEnvironment
impl Debug for TypeEnvironment
Source§impl Default for TypeEnvironment
impl Default for TypeEnvironment
Source§fn default() -> TypeEnvironment
fn default() -> TypeEnvironment
Source§impl TypeResolver for TypeEnvironment
impl TypeResolver for TypeEnvironment
Source§fn resolve_ref(
&self,
symbol: SymbolRef,
_interner: &dyn TypeDatabase,
) -> Option<TypeId>
fn resolve_ref( &self, symbol: SymbolRef, _interner: &dyn TypeDatabase, ) -> Option<TypeId>
Source§fn resolve_lazy(
&self,
def_id: DefId,
_interner: &dyn TypeDatabase,
) -> Option<TypeId>
fn resolve_lazy( &self, def_id: DefId, _interner: &dyn TypeDatabase, ) -> Option<TypeId>
DefId reference to its structural type. Read moreSource§fn get_type_params(&self, symbol: SymbolRef) -> Option<Vec<TypeParamInfo>>
fn get_type_params(&self, symbol: SymbolRef) -> Option<Vec<TypeParamInfo>>
Source§fn get_lazy_type_params(&self, def_id: DefId) -> Option<Vec<TypeParamInfo>>
fn get_lazy_type_params(&self, def_id: DefId) -> Option<Vec<TypeParamInfo>>
DefId (for generic type aliases/interfaces). Read moreSource§fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>
fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>
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
fn is_boxed_def_id(&self, def_id: DefId, kind: IntrinsicKind) -> bool
DefId corresponds to a boxed type for the given intrinsic kind.Source§fn is_boxed_type_id(&self, type_id: TypeId, kind: IntrinsicKind) -> bool
fn is_boxed_type_id(&self, type_id: TypeId, kind: IntrinsicKind) -> bool
TypeId is any known resolved form of a boxed type. Read moreSource§fn get_array_base_type(&self) -> Option<TypeId>
fn get_array_base_type(&self) -> Option<TypeId>
Source§fn get_array_base_type_params(&self) -> &[TypeParamInfo]
fn get_array_base_type_params(&self) -> &[TypeParamInfo]
Source§fn is_numeric_enum(&self, def_id: DefId) -> bool
fn is_numeric_enum(&self, def_id: DefId) -> bool
DefId corresponds to a numeric enum (not a string enum). Read moreSource§fn is_user_enum_def(&self, _def_id: DefId) -> bool
fn is_user_enum_def(&self, _def_id: DefId) -> bool
DefId represents a user-defined enum (not an intrinsic type).Source§fn resolve_symbol_ref(
&self,
symbol: SymbolRef,
interner: &dyn TypeDatabase,
) -> Option<TypeId>
fn resolve_symbol_ref( &self, symbol: SymbolRef, interner: &dyn TypeDatabase, ) -> Option<TypeId>
Source§fn get_lazy_export(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
fn get_lazy_export(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
Source§fn get_lazy_enum_member(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
fn get_lazy_enum_member(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
DefId. Read moreSource§fn is_enum_type(&self, _type_id: TypeId, _interner: &dyn TypeDatabase) -> bool
fn is_enum_type(&self, _type_id: TypeId, _interner: &dyn TypeDatabase) -> bool
TypeId represents a full Enum type (not a specific member).