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() -> TypeEnv
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,
) -> TypeEnv
pub fn infer_program( stmts: &[Stmt<'_>], interner: &Interner, _registry: &TypeRegistry, ) -> TypeEnv
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.