Skip to main content

SymbolTable

Struct SymbolTable 

Source
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

Source

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.

Source

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.

Source

pub fn type_id_of(&self, key: &TypeKey) -> Option<TypeId>

Resolve a TypeKey to its TypeId.

Source

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.

Source

pub fn ctor_id_of(&self, owning_type: TypeId, variant: &str) -> Option<CtorId>

Resolve a constructor by (owning type, variant name).

Source

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.

Source

pub fn type_entry(&self, id: TypeId) -> &TypeEntry

Source

pub fn ctor_entry(&self, id: CtorId) -> &CtorEntry

Source

pub fn module_entry(&self, id: ModuleId) -> &ModuleEntry

Source

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

Source

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.

Source

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

Source§

fn clone(&self) -> SymbolTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SymbolTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SymbolTable

Source§

fn default() -> SymbolTable

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, 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> 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