pub struct TypeEnvironment { /* private fields */ }Implementations§
Source§impl TypeEnvironment
impl TypeEnvironment
pub fn new() -> Self
Sourcepub fn define_builtin_functions(&mut self)
pub fn define_builtin_functions(&mut self)
Add built-in functions
Sourcepub fn define(&mut self, name: &str, scheme: TypeScheme)
pub fn define(&mut self, name: &str, scheme: TypeScheme)
Define a variable in the current scope
Sourcepub fn lookup(&self, name: &str) -> Option<&TypeScheme>
pub fn lookup(&self, name: &str) -> Option<&TypeScheme>
Look up a variable type
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Push a new scope
Sourcepub fn define_type_alias(
&mut self,
name: &str,
ty: &TypeAnnotation,
meta_param_overrides: Option<HashMap<String, Expr>>,
)
pub fn define_type_alias( &mut self, name: &str, ty: &TypeAnnotation, meta_param_overrides: Option<HashMap<String, Expr>>, )
Define a type alias with optional meta parameter overrides
Sourcepub fn lookup_type_alias(&self, name: &str) -> Option<&TypeAliasEntry>
pub fn lookup_type_alias(&self, name: &str) -> Option<&TypeAliasEntry>
Look up a type alias
Sourcepub fn get_type_alias_meta_overrides(
&self,
name: &str,
) -> Option<&HashMap<String, Expr>>
pub fn get_type_alias_meta_overrides( &self, name: &str, ) -> Option<&HashMap<String, Expr>>
Get the meta parameter overrides for a type alias
Sourcepub fn define_interface(&mut self, interface: &InterfaceDef)
pub fn define_interface(&mut self, interface: &InterfaceDef)
Define an interface
Sourcepub fn lookup_interface(&self, name: &str) -> Option<&InterfaceDef>
pub fn lookup_interface(&self, name: &str) -> Option<&InterfaceDef>
Look up an interface
Sourcepub fn define_trait(&mut self, trait_def: &TraitDef)
pub fn define_trait(&mut self, trait_def: &TraitDef)
Define a trait
Sourcepub fn lookup_trait(&self, name: &str) -> Option<&TraitDef>
pub fn lookup_trait(&self, name: &str) -> Option<&TraitDef>
Look up a trait
Sourcepub fn register_trait_impl(
&mut self,
trait_name: &str,
target_type: &str,
method_names: Vec<String>,
) -> Result<(), String>
pub fn register_trait_impl( &mut self, trait_name: &str, target_type: &str, method_names: Vec<String>, ) -> Result<(), String>
Register a trait implementation with validation
Sourcepub fn register_trait_impl_named(
&mut self,
trait_name: &str,
target_type: &str,
impl_name: &str,
method_names: Vec<String>,
) -> Result<(), String>
pub fn register_trait_impl_named( &mut self, trait_name: &str, target_type: &str, impl_name: &str, method_names: Vec<String>, ) -> Result<(), String>
Register a named trait implementation
Sourcepub fn register_trait_impl_with_assoc_types(
&mut self,
trait_name: &str,
target_type: &str,
method_names: Vec<String>,
associated_types: HashMap<String, TypeAnnotation>,
) -> Result<(), String>
pub fn register_trait_impl_with_assoc_types( &mut self, trait_name: &str, target_type: &str, method_names: Vec<String>, associated_types: HashMap<String, TypeAnnotation>, ) -> Result<(), String>
Register a trait implementation with associated type bindings
Sourcepub fn register_trait_impl_with_assoc_types_named(
&mut self,
trait_name: &str,
target_type: &str,
impl_name: Option<&str>,
method_names: Vec<String>,
associated_types: HashMap<String, TypeAnnotation>,
) -> Result<(), String>
pub fn register_trait_impl_with_assoc_types_named( &mut self, trait_name: &str, target_type: &str, impl_name: Option<&str>, method_names: Vec<String>, associated_types: HashMap<String, TypeAnnotation>, ) -> Result<(), String>
Register a named trait implementation with associated type bindings
Sourcepub fn type_implements_trait(&self, type_name: &str, trait_name: &str) -> bool
pub fn type_implements_trait(&self, type_name: &str, trait_name: &str) -> bool
Check if a type implements a trait
Sourcepub fn lookup_trait_impl(
&self,
trait_name: &str,
type_name: &str,
) -> Option<&TraitImplEntry>
pub fn lookup_trait_impl( &self, trait_name: &str, type_name: &str, ) -> Option<&TraitImplEntry>
Look up a trait implementation
Sourcepub fn lookup_trait_impl_named(
&self,
trait_name: &str,
type_name: &str,
impl_name: &str,
) -> Option<&TraitImplEntry>
pub fn lookup_trait_impl_named( &self, trait_name: &str, type_name: &str, impl_name: &str, ) -> Option<&TraitImplEntry>
Look up a named trait implementation
Sourcepub fn resolve_associated_type(
&self,
trait_name: &str,
type_name: &str,
assoc_type_name: &str,
) -> Option<&TypeAnnotation>
pub fn resolve_associated_type( &self, trait_name: &str, type_name: &str, assoc_type_name: &str, ) -> Option<&TypeAnnotation>
Resolve an associated type from a trait implementation
Sourcepub fn resolve_associated_type_named(
&self,
trait_name: &str,
type_name: &str,
impl_name: &str,
assoc_type_name: &str,
) -> Option<&TypeAnnotation>
pub fn resolve_associated_type_named( &self, trait_name: &str, type_name: &str, impl_name: &str, assoc_type_name: &str, ) -> Option<&TypeAnnotation>
Resolve an associated type from a named trait implementation
Sourcepub fn trait_impl_keys(&self) -> HashSet<String>
pub fn trait_impl_keys(&self) -> HashSet<String>
Get all trait implementation keys (“TraitName::TypeName”) as a set
Sourcepub fn get_transitive_supertrait_names(&self, trait_name: &str) -> Vec<String>
pub fn get_transitive_supertrait_names(&self, trait_name: &str) -> Vec<String>
Get the transitive closure of supertrait names for a given trait.
Given trait A: B, trait B: C, returns ["B", "C"] for “A”.
Sourcepub fn register_blanket_impl(
&mut self,
trait_name: &str,
required_bounds: Vec<String>,
method_names: Vec<String>,
)
pub fn register_blanket_impl( &mut self, trait_name: &str, required_bounds: Vec<String>, method_names: Vec<String>, )
Register a blanket implementation: impl<T: Bound> Trait for T
Sourcepub fn register_enum(&mut self, enum_def: &EnumDef)
pub fn register_enum(&mut self, enum_def: &EnumDef)
Register an enum definition for exhaustiveness checking
Sourcepub fn register_record_schema(&mut self, name: &str, schema: RecordSchema)
pub fn register_record_schema(&mut self, name: &str, schema: RecordSchema)
Register a record schema
Sourcepub fn lookup_record_schema(&self, name: &str) -> Option<&RecordSchema>
pub fn lookup_record_schema(&self, name: &str) -> Option<&RecordSchema>
Look up a record schema
Sourcepub fn get_record_field_type(
&self,
schema_name: &str,
field_name: &str,
) -> Option<&TypeAnnotation>
pub fn get_record_field_type( &self, schema_name: &str, field_name: &str, ) -> Option<&TypeAnnotation>
Get field type from a record schema
Sourcepub fn record_has_field(&self, schema_name: &str, field_name: &str) -> bool
pub fn record_has_field(&self, schema_name: &str, field_name: &str) -> bool
Check if a record schema has a field
Sourcepub fn generalize(&self, ty: &Type) -> TypeScheme
pub fn generalize(&self, ty: &Type) -> TypeScheme
Generalize a type by quantifying free type variables
Sourcepub fn register_hoisted_field(
&mut self,
var_name: &str,
field_name: &str,
field_type: Type,
)
pub fn register_hoisted_field( &mut self, var_name: &str, field_name: &str, field_type: Type, )
Register a hoisted field for a variable (called during pre-pass)
Sourcepub fn get_hoisted_fields(&self, var_name: &str) -> Option<&Vec<HoistedField>>
pub fn get_hoisted_fields(&self, var_name: &str) -> Option<&Vec<HoistedField>>
Get all hoisted fields for a variable
Sourcepub fn set_current_access_variable(&mut self, var_name: Option<String>)
pub fn set_current_access_variable(&mut self, var_name: Option<String>)
Set the current variable being accessed (for property access inference)
Sourcepub fn get_current_access_variable(&self) -> Option<&String>
pub fn get_current_access_variable(&self) -> Option<&String>
Get the current variable being accessed
Sourcepub fn mark_hoisted_field_initialized(
&mut self,
var_name: &str,
field_name: &str,
)
pub fn mark_hoisted_field_initialized( &mut self, var_name: &str, field_name: &str, )
Mark a hoisted field as initialized after a write (a.y = ...).
Sourcepub fn is_hoisted_field_initialized(
&self,
var_name: &str,
field_name: &str,
) -> bool
pub fn is_hoisted_field_initialized( &self, var_name: &str, field_name: &str, ) -> bool
Check whether a hoisted field has been initialized by a write.
Sourcepub fn get_hoisted_field(&self, field_name: &str) -> Option<Type>
pub fn get_hoisted_field(&self, field_name: &str) -> Option<Type>
Get a hoisted field type for the current access variable in read context. Field is only visible after it has been initialized by assignment.
Sourcepub fn get_hoisted_field_for_assignment(&self, field_name: &str) -> Option<Type>
pub fn get_hoisted_field_for_assignment(&self, field_name: &str) -> Option<Type>
Get a hoisted field type for the current access variable in assignment context. Assignment targets may reference hoisted fields before first write.
Sourcepub fn clear_hoisted_fields(&mut self)
pub fn clear_hoisted_fields(&mut self)
Clear all hoisted fields (for resetting between analyses)
Sourcepub fn upsert_object_field(
&mut self,
var_name: &str,
field_name: &str,
field_type: Type,
)
pub fn upsert_object_field( &mut self, var_name: &str, field_name: &str, field_type: Type, )
Evolve an in-scope object variable by adding/updating a field.
This keeps runtime-inferred object types in sync with successful property
assignments so later expressions (e.g., a + b) observe the evolved shape.
Sourcepub fn begin_evolution(&mut self, var_name: &str, initial_type: SemanticType)
pub fn begin_evolution(&mut self, var_name: &str, initial_type: SemanticType)
Begin tracking type evolution for a variable
Sourcepub fn record_field_assignment(
&mut self,
var_name: &str,
field_name: &str,
field_type: SemanticType,
) -> TypeResult<()>
pub fn record_field_assignment( &mut self, var_name: &str, field_name: &str, field_type: SemanticType, ) -> TypeResult<()>
Record a field assignment for type evolution tracking
Sourcepub fn get_evolved_type(&self, var_name: &str) -> Option<SemanticType>
pub fn get_evolved_type(&self, var_name: &str) -> Option<SemanticType>
Get the current evolved type for a variable
Sourcepub fn get_evolution(&self, var_name: &str) -> Option<&TypeEvolution>
pub fn get_evolution(&self, var_name: &str) -> Option<&TypeEvolution>
Get the type evolution for a variable
Sourcepub fn enter_conditional(&mut self)
pub fn enter_conditional(&mut self)
Enter a conditional block (if/else)
Sourcepub fn exit_conditional(&mut self)
pub fn exit_conditional(&mut self)
Exit a conditional block
Sourcepub fn enter_loop(&mut self)
pub fn enter_loop(&mut self)
Enter a loop block (for/while)
Sourcepub fn in_conditional_context(&self) -> bool
pub fn in_conditional_context(&self) -> bool
Check if we’re inside a conditional or loop context
Sourcepub fn all_evolutions(&self) -> &HashMap<String, TypeEvolution>
pub fn all_evolutions(&self) -> &HashMap<String, TypeEvolution>
Get all type evolutions
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
Auto Trait Implementations§
impl Freeze for TypeEnvironment
impl RefUnwindSafe for TypeEnvironment
impl Send for TypeEnvironment
impl Sync for TypeEnvironment
impl Unpin for TypeEnvironment
impl UnsafeUnpin for TypeEnvironment
impl UnwindSafe for TypeEnvironment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more