pub struct TypeEnv { /* private fields */ }Expand description
Type environment built by a forward pass over the AST.
Computed once before codegen and shared immutably. Replaces the
variable_types: HashMap<Symbol, String> and string_vars: HashSet<Symbol>
that were incrementally built during codegen.
Implementations§
Source§impl TypeEnv
impl TypeEnv
pub fn new() -> Self
Sourcepub fn register_fn(&mut self, sym: Symbol, sig: FnSig)
pub fn register_fn(&mut self, sym: Symbol, sig: FnSig)
Register a function signature.
Sourcepub fn infer_expr(&self, expr: &Expr<'_>, interner: &Interner) -> LogosType
pub fn infer_expr(&self, expr: &Expr<'_>, interner: &Interner) -> LogosType
Infer the type of an expression given the current environment.
Sourcepub fn infer_program(
stmts: &[Stmt<'_>],
interner: &Interner,
_registry: &TypeRegistry,
) -> Self
pub fn infer_program( stmts: &[Stmt<'_>], interner: &Interner, _registry: &TypeRegistry, ) -> Self
Build a TypeEnv from a program’s statements via a single forward pass.
For each statement, registers variable types and function signatures into the environment. Since LOGOS programs are forward-declared, no fixpoint iteration is needed.
Sourcepub fn to_logos_type_map(&self) -> HashMap<Symbol, LogosType>
pub fn to_logos_type_map(&self) -> HashMap<Symbol, LogosType>
Export the type environment as a LogosType map for RefinementContext seeding.
Sourcepub fn to_legacy_variable_types(&self) -> HashMap<Symbol, String>
pub fn to_legacy_variable_types(&self) -> HashMap<Symbol, String>
Convert the type environment to the legacy string-based format.
Sourcepub fn to_legacy_string_vars(&self) -> HashSet<Symbol>
pub fn to_legacy_string_vars(&self) -> HashSet<Symbol>
Convert the type environment to the legacy string var set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeEnv
impl RefUnwindSafe for TypeEnv
impl Send for TypeEnv
impl Sync for TypeEnv
impl Unpin for TypeEnv
impl UnsafeUnpin for TypeEnv
impl UnwindSafe for TypeEnv
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.