Skip to main content

TypeEnvironment

Struct TypeEnvironment 

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

Implementations§

Source§

impl TypeEnvironment

Source

pub fn new() -> Self

Source

pub fn define_builtin_functions(&mut self)

Add built-in financial analysis functions

Source

pub fn define(&mut self, name: &str, scheme: TypeScheme)

Define a variable in the current scope

Source

pub fn lookup(&self, name: &str) -> Option<&TypeScheme>

Look up a variable type

Source

pub fn push_scope(&mut self)

Push a new scope

Source

pub fn pop_scope(&mut self)

Pop the current scope

Source

pub fn import_from_symbol_table(&mut self, symbol_table: &SymbolTable)

Import symbols from a SymbolTable into this TypeEnvironment

This syncs the semantic analyzer’s symbol table with the type inference engine’s environment, allowing the inference engine to see all defined variables, functions, and type aliases.

Source

pub fn import_variable(&mut self, name: &str, legacy_type: &Type)

Import a single variable from a SymbolTable

Source

pub fn import_function(&mut self, name: &str, params: &[Type], returns: &Type)

Import a single function from a SymbolTable

Source

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

Source

pub fn lookup_type_alias(&self, name: &str) -> Option<&TypeAliasEntry>

Look up a type alias

Source

pub fn get_type_alias_meta_overrides( &self, name: &str, ) -> Option<&HashMap<String, Expr>>

Get the meta parameter overrides for a type alias

Source

pub fn define_interface(&mut self, interface: &InterfaceDef)

Define an interface

Source

pub fn lookup_interface(&self, name: &str) -> Option<&InterfaceDef>

Look up an interface

Source

pub fn define_trait(&mut self, trait_def: &TraitDef)

Define a trait

Source

pub fn lookup_trait(&self, name: &str) -> Option<&TraitDef>

Look up a trait

Source

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

Source

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

Source

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

Source

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

Source

pub fn type_implements_trait(&self, type_name: &str, trait_name: &str) -> bool

Check if a type implements a trait

Source

pub fn lookup_trait_impl( &self, trait_name: &str, type_name: &str, ) -> Option<&TraitImplEntry>

Look up a trait implementation

Source

pub fn lookup_trait_impl_named( &self, trait_name: &str, type_name: &str, impl_name: &str, ) -> Option<&TraitImplEntry>

Look up a named trait implementation

Source

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

Source

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

Source

pub fn trait_impl_keys(&self) -> HashSet<String>

Get all trait implementation keys (“TraitName::TypeName”) as a set

Source

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

Source

pub fn register_enum(&mut self, enum_def: &EnumDef)

Register an enum definition for exhaustiveness checking

Source

pub fn get_enum(&self, name: &str) -> Option<&EnumDef>

Look up an enum definition by name

Source

pub fn register_record_schema(&mut self, name: &str, schema: RecordSchema)

Register a record schema

Source

pub fn lookup_record_schema(&self, name: &str) -> Option<&RecordSchema>

Look up a record schema

Source

pub fn get_record_field_type( &self, schema_name: &str, field_name: &str, ) -> Option<&TypeAnnotation>

Get field type from a record schema

Source

pub fn record_has_field(&self, schema_name: &str, field_name: &str) -> bool

Check if a record schema has a field

Source

pub fn generalize(&self, ty: &Type) -> TypeScheme

Generalize a type by quantifying free type variables

Source

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)

Source

pub fn get_hoisted_fields(&self, var_name: &str) -> Option<&Vec<HoistedField>>

Get all hoisted fields for a variable

Source

pub fn set_current_access_variable(&mut self, var_name: Option<String>)

Set the current variable being accessed (for property access inference)

Source

pub fn get_current_access_variable(&self) -> Option<&String>

Get the current variable being accessed

Source

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 = ...).

Source

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.

Source

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.

Source

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.

Source

pub fn clear_hoisted_fields(&mut self)

Clear all hoisted fields (for resetting between analyses)

Source

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.

Source

pub fn begin_evolution(&mut self, var_name: &str, initial_type: SemanticType)

Begin tracking type evolution for a variable

Source

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

Source

pub fn get_evolved_type(&self, var_name: &str) -> Option<SemanticType>

Get the current evolved type for a variable

Source

pub fn get_evolution(&self, var_name: &str) -> Option<&TypeEvolution>

Get the type evolution for a variable

Source

pub fn enter_conditional(&mut self)

Enter a conditional block (if/else)

Source

pub fn exit_conditional(&mut self)

Exit a conditional block

Source

pub fn enter_loop(&mut self)

Enter a loop block (for/while)

Source

pub fn exit_loop(&mut self)

Exit a loop block

Source

pub fn in_conditional_context(&self) -> bool

Check if we’re inside a conditional or loop context

Source

pub fn all_evolutions(&self) -> &HashMap<String, TypeEvolution>

Get all type evolutions

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() -> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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: 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: 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 = 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,