pub struct SymbolTable {
pub modules: Vec<ModuleEntry>,
pub fns: Vec<FnEntry>,
pub types: Vec<TypeEntry>,
pub ctors: Vec<CtorEntry>,
pub builtins: Vec<BuiltinEntry>,
/* private fields */
}Expand description
Resolved-identity table for an Aver program. Built once after module load + before typecheck (eventually — today no caller invokes this yet); consumers thereafter look up IDs and never re-resolve names.
Fields§
§modules: Vec<ModuleEntry>§fns: Vec<FnEntry>§types: Vec<TypeEntry>§ctors: Vec<CtorEntry>§builtins: Vec<BuiltinEntry>Phase 6 wave 11 — interned built-in function names. Grows
lazily as lower_program encounters new
ResolvedCallee::Builtin(name) shapes via
SymbolTable::intern_builtin. Re-interning the same name
returns the same BuiltinId so MIR’s call sites end up
with stable identity per program.
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn build(entry_items: &[TopLevel], dep_modules: &[ModuleInfo]) -> Self
pub fn build(entry_items: &[TopLevel], dep_modules: &[ModuleInfo]) -> Self
Build a SymbolTable from entry items + dep modules. The
build order is fully deterministic: modules in
dep_modules walk order with the entry scope prepended,
fns in source order within each module, types in source
order within each module, ctors in variant-source order
within each type.
Sourcepub fn fn_id_of(&self, key: &FnKey) -> Option<FnId>
pub fn fn_id_of(&self, key: &FnKey) -> Option<FnId>
Resolve a FnKey to its FnId. None when the key
doesn’t name any function in the program.
Sourcepub fn type_id_of(&self, key: &TypeKey) -> Option<TypeId>
pub fn type_id_of(&self, key: &TypeKey) -> Option<TypeId>
Resolve a TypeKey to its TypeId.
Sourcepub fn type_id_by_bare_name(&self, name: &str) -> Option<TypeId>
pub fn type_id_by_bare_name(&self, name: &str) -> Option<TypeId>
Resolve a bare type name (no module prefix) against every
scope in the table — entry first, then each dep module — and
return the unique match. Returns None when the name doesn’t
resolve OR when two or more scopes legitimately share it
(ambiguous reference; caller must qualify).
Phase-E cross-module ctor resolution: an Aver expression like
Val.ValOk(x) written from a module that doesn’t host the
Val type still needs to resolve to the right TypeId so the
resolver can lift the call to ResolvedCtor::User. Pre-PR-8
the rust codegen worked around the gap by matching ctors by
raw string after the resolver had moved on; PR 8 made the
resolved-form classification authoritative, which exposed
this missing lookup. Adding it here keeps identity logic on
the symbol table where the rest of identity resolution lives.
Sourcepub fn ctor_id_of(&self, owning_type: TypeId, variant: &str) -> Option<CtorId>
pub fn ctor_id_of(&self, owning_type: TypeId, variant: &str) -> Option<CtorId>
Resolve a constructor by (owning type, variant name).
Sourcepub fn fn_entry(&self, id: FnId) -> &FnEntry
pub fn fn_entry(&self, id: FnId) -> &FnEntry
Borrow the entry for a FnId. Panics on an invalid FnId
— the only way to obtain one is through this table, so an
invalid FnId is a logic error, not a runtime input
failure.
pub fn type_entry(&self, id: TypeId) -> &TypeEntry
pub fn ctor_entry(&self, id: CtorId) -> &CtorEntry
pub fn module_entry(&self, id: ModuleId) -> &ModuleEntry
Sourcepub fn builtin_entry(&self, id: BuiltinId) -> &BuiltinEntry
pub fn builtin_entry(&self, id: BuiltinId) -> &BuiltinEntry
Phase 6 wave 11 — look up an interned built-in name. Panics
the same way the other *_entry lookups do when the id is
out of range (consumers should always hold ids minted by
intern_builtin).
Sourcepub fn intern_builtin(&mut self, name: &str) -> BuiltinId
pub fn intern_builtin(&mut self, name: &str) -> BuiltinId
Phase 6 wave 11 — intern a built-in fn name. Returns the
stable BuiltinId for name, reusing the existing slot
when the name has already been interned. Callers
(lower_program for the MIR side) get the same id for the
same name across the whole program so MIR consumers can
compare callees by identity.
Sourcepub fn builtin_id_of(&self, name: &str) -> Option<BuiltinId>
pub fn builtin_id_of(&self, name: &str) -> Option<BuiltinId>
Phase 6 wave 11 — look up a BuiltinId by name without
interning. Returns None when the name hasn’t been
registered yet. Useful for consumers that want to detect
“is this name a known builtin” without mutating state.
Trait Implementations§
Source§impl Clone for SymbolTable
impl Clone for SymbolTable
Source§fn clone(&self) -> SymbolTable
fn clone(&self) -> SymbolTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more