pub struct ResolveCtx<'a> {
pub symbols: &'a SymbolTable,
pub current_module: Option<String>,
}Expand description
Resolver state. Carries the symbol table the pass resolves
against and the module prefix the current item lives in. The
prefix matters for entry items that declare module Main — the
symbol table stores them under FnKey::entry / TypeKey::entry,
but the source-level references inside their bodies still use
the interior name, so the resolver needs both candidates to
match Phase B’s canonical resolution rules.
Fields§
§symbols: &'a SymbolTable§current_module: Option<String>Implementations§
Source§impl<'a> ResolveCtx<'a>
impl<'a> ResolveCtx<'a>
pub fn new(symbols: &'a SymbolTable) -> Self
Sourcepub fn resolve_fn_id(&self, name: &str) -> Option<FnId>
pub fn resolve_fn_id(&self, name: &str) -> Option<FnId>
Resolve a fn reference to a FnId. Tries (in order):
- Qualified:
Module.fn→FnKey::in_module(Module, fn). - Current module:
fn→FnKey::in_module(current, fn). - Current-as-entry: when the qualified prefix matches the
current module, also probe
FnKey::entry(fn)(entry items live under entry scope in the symbol table even when they declaremodule X). - Entry:
fn→FnKey::entry(fn).
Sourcepub fn resolve_type_id(&self, name: &str) -> Option<TypeId>
pub fn resolve_type_id(&self, name: &str) -> Option<TypeId>
Type-side equivalent of Self::resolve_fn_id.
Resolution order (first match wins):
prefix.namematchesTypeKey::in_module(prefix, name).prefix.namewithprefix == current_modulematches the entry-scopeTypeKey::entry(name)(Aver lets a self-referencing module spell its own type with the qualified form).- Bare
nameincurrent_module(TypeKey::in_module(current, name)). - Bare
namein entry scope (TypeKey::entry(name)). - Bare
namesearched across every scope viacrate::ir::SymbolTable::type_id_by_bare_name— handles the cross-module case where moduleAreferences typeValdeclared in moduleBwithout qualification. ReturnsNonewhen ambiguous (caller must qualify).
Auto Trait Implementations§
impl<'a> Freeze for ResolveCtx<'a>
impl<'a> RefUnwindSafe for ResolveCtx<'a>
impl<'a> Send for ResolveCtx<'a>
impl<'a> Sync for ResolveCtx<'a>
impl<'a> Unpin for ResolveCtx<'a>
impl<'a> UnsafeUnpin for ResolveCtx<'a>
impl<'a> UnwindSafe for ResolveCtx<'a>
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
Mutably borrows from an owned value. Read more