Skip to main content

ResolveCtx

Struct ResolveCtx 

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

Source

pub fn new(symbols: &'a SymbolTable) -> Self

Source

pub fn resolve_fn_id(&self, name: &str) -> Option<FnId>

Resolve a fn reference to a FnId. Tries (in order):

  1. Qualified: Module.fnFnKey::in_module(Module, fn).
  2. Current module: fnFnKey::in_module(current, fn).
  3. 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 declare module X).
  4. Entry: fnFnKey::entry(fn).
Source

pub fn resolve_type_id(&self, name: &str) -> Option<TypeId>

Type-side equivalent of Self::resolve_fn_id.

Resolution order (first match wins):

  1. prefix.name matches TypeKey::in_module(prefix, name).
  2. prefix.name with prefix == current_module matches the entry-scope TypeKey::entry(name) (Aver lets a self-referencing module spell its own type with the qualified form).
  3. Bare name in current_module (TypeKey::in_module(current, name)).
  4. Bare name in entry scope (TypeKey::entry(name)).
  5. Bare name searched across every scope via crate::ir::SymbolTable::type_id_by_bare_name — handles the cross-module case where module A references type Val declared in module B without qualification. Returns None when ambiguous (caller must qualify).
Source

pub fn resolve_user_ctor( &self, dotted: &str, ) -> Option<(CtorId, TypeId, String)>

Resolve a "Type.Variant" constructor reference to a (CtorId, TypeId, variant_name) triple.

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