pub struct ModuleResolver { /* private fields */ }Expand description
Project-wide module resolver backed by canonical DagId identities.
Implementations§
Source§impl ModuleResolver
impl ModuleResolver
Sourcepub fn from_modules<'a>(
modules: impl IntoIterator<Item = (DagId, &'a File)>,
) -> Result<Self, ModuleResolveError>
pub fn from_modules<'a>( modules: impl IntoIterator<Item = (DagId, &'a File)>, ) -> Result<Self, ModuleResolveError>
Build a resolver from (DagId, File) pairs without registering any
import scopes.
Call Self::register_import / Self::register_include for each
loader-resolved edge after all modules have been added.
§Errors
Returns ModuleResolveError on duplicate modules or duplicate symbols.
Sourcepub fn add_module(
&mut self,
owner: DagId,
declarations: &[Declaration],
) -> Result<(), ModuleResolveError>
pub fn add_module( &mut self, owner: DagId, declarations: &[Declaration], ) -> Result<(), ModuleResolveError>
Add one module’s declaration symbols.
§Errors
Returns ModuleResolveError::DuplicateModule when owner already has
a symbol table, or ModuleResolveError::DuplicateSymbol for duplicate
namespace-local definitions inside the module.
Sourcepub const fn modules(&self) -> &HashMap<DagId, ModuleSymbols>
pub const fn modules(&self) -> &HashMap<DagId, ModuleSymbols>
Borrow all module symbol tables.
Sourcepub const fn scopes(&self) -> &HashMap<DagId, ModuleScope>
pub const fn scopes(&self) -> &HashMap<DagId, ModuleScope>
Borrow all module import scopes.
Sourcepub fn register_import(
&mut self,
owner: &DagId,
path: &ModulePath,
kind: &ImportKind,
target: &DagId,
) -> Result<(), ModuleResolveError>
pub fn register_import( &mut self, owner: &DagId, path: &ModulePath, kind: &ImportKind, target: &DagId, ) -> Result<(), ModuleResolveError>
Register one loader-resolved import edge in owner’s scope.
path and kind come from the source AST. target is the canonical
module identity chosen by the loader for that path. This function never
re-resolves filesystem paths.
§Errors
Returns ModuleResolveError if either module is unknown, an imported
item is missing/private, or the import introduces a duplicate local name.
Sourcepub fn register_include(
&mut self,
owner: &DagId,
path: &ModulePath,
kind: &ImportKind,
target: &DagId,
) -> Result<(), ModuleResolveError>
pub fn register_include( &mut self, owner: &DagId, path: &ModulePath, kind: &ImportKind, target: &DagId, ) -> Result<(), ModuleResolveError>
Register one loader-resolved include edge in owner’s scope.
Instantiated includes embed the dependency DAG body, but the source-level names introduced by the include are still a cross-module boundary and must preserve public visibility.
Sourcepub fn inline_instantiated_include_indexes(
&mut self,
importer: &DagId,
source: &DagId,
bound: &HashSet<&str>,
) -> Result<(), ModuleResolveError>
pub fn inline_instantiated_include_indexes( &mut self, importer: &DagId, source: &DagId, bound: &HashSet<&str>, ) -> Result<(), ModuleResolveError>
Make an instantiated include’s own indexes resolvable in the importer.
An instantiated include inlines the dependency’s declaration bodies
into the importer (see ir::lower::merge_dependency). Those bodies
reference the dependency’s own indexes by their bare names (for s: Step, T[Step], Step.A), which are not bound to any importer symbol.
The dependency’s declarations live in the synthetic include module
source; copy each of its index symbols — re-homed onto the importer so
they resolve against the flat merged registry that backs the importer’s
declarations — into the importer’s own symbol table, variants included.
Indexes named in bound (the include’s index bindings/overrides) are
skipped: a bound index is rewritten to the importer’s replacement before
resolution, so the dependency’s original name must not shadow it.
Indexes already declared in the importer are likewise left untouched.
§Errors
Returns ModuleResolveError::UnknownModule if either module is absent
from the resolver.
Sourcepub fn resolve_decl_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedName<Decl>, ModuleResolveError>
pub fn resolve_decl_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedName<Decl>, ModuleResolveError>
Resolve a syntactic declaration/value path to a canonical owner + leaf.
Bare paths first search local declarations, then selective imports. Qualified paths resolve their qualifier through module aliases and then apply that alias boundary’s visibility rule.
Sourcepub fn resolve_const_decl_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedName<Decl>, ModuleResolveError>
pub fn resolve_const_decl_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedName<Decl>, ModuleResolveError>
Resolve a declaration path and require that it names a const declaration.
Sourcepub fn decl_symbol_kind(
&self,
name: &ResolvedName<Decl>,
) -> Result<DeclSymbolKind, ModuleResolveError>
pub fn decl_symbol_kind( &self, name: &ResolvedName<Decl>, ) -> Result<DeclSymbolKind, ModuleResolveError>
Return the semantic kind of a resolved declaration symbol.
Sourcepub fn resolve_dimension_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedName<Dim>, ModuleResolveError>
pub fn resolve_dimension_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedName<Dim>, ModuleResolveError>
Resolve a syntactic dimension path to a canonical owner + leaf.
Sourcepub fn resolve_unit_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedName<Unit>, ModuleResolveError>
pub fn resolve_unit_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedName<Unit>, ModuleResolveError>
Resolve a syntactic unit path to a canonical owner + leaf.
Sourcepub fn resolve_struct_type_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedName<StructType>, ModuleResolveError>
pub fn resolve_struct_type_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedName<StructType>, ModuleResolveError>
Resolve a syntactic struct/tagged-union type path to a canonical owner + leaf.
Sourcepub fn resolve_constructor_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedName<Constructor>, ModuleResolveError>
pub fn resolve_constructor_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedName<Constructor>, ModuleResolveError>
Resolve a syntactic tagged-union constructor path to a canonical owner + leaf.
Sourcepub fn resolve_constructor_ident_path(
&self,
owner: &DagId,
path: &IdentPath,
) -> Result<ResolvedName<Constructor>, ModuleResolveError>
pub fn resolve_constructor_ident_path( &self, owner: &DagId, path: &IdentPath, ) -> Result<ResolvedName<Constructor>, ModuleResolveError>
Resolve a span-aware constructor path without losing source path shape at the caller boundary.
Sourcepub fn resolve_index_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedName<Index>, ModuleResolveError>
pub fn resolve_index_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedName<Index>, ModuleResolveError>
Resolve a syntactic index path to a canonical owner + leaf.
Sourcepub fn resolve_index_variant_path(
&self,
owner: &DagId,
path: &NamePath,
) -> Result<ResolvedIndexVariant, ModuleResolveError>
pub fn resolve_index_variant_path( &self, owner: &DagId, path: &NamePath, ) -> Result<ResolvedIndexVariant, ModuleResolveError>
Resolve a syntactic index-variant path such as Index.Variant or
module.Index.Variant.
Sourcepub fn resolve_index_variant_parts(
&self,
owner: &DagId,
index_path: &NamePath,
variant: &IndexVariantName,
) -> Result<ResolvedIndexVariant, ModuleResolveError>
pub fn resolve_index_variant_parts( &self, owner: &DagId, index_path: &NamePath, variant: &IndexVariantName, ) -> Result<ResolvedIndexVariant, ModuleResolveError>
Resolve an already-split index path plus variant leaf to a canonical index-variant identity.
This is the HIR-facing form for parser positions that preserve the index path and variant leaf separately (map keys, index arguments, and match labels). It avoids reconstructing a dotted string or re-parsing source text just to validate the variant against the canonical index.
Sourcepub fn resolve_bare_index_variant(
&self,
owner: &DagId,
variant: &IndexVariantName,
) -> Result<ResolvedIndexVariant, ModuleResolveError>
pub fn resolve_bare_index_variant( &self, owner: &DagId, variant: &IndexVariantName, ) -> Result<ResolvedIndexVariant, ModuleResolveError>
Resolve a bare variant leaf by searching local and selectively imported indexes in the current module scope.
Sourcepub fn resolve_module_path(
&self,
owner: &DagId,
path: &ModulePath,
) -> Result<DagId, ModuleResolveError>
pub fn resolve_module_path( &self, owner: &DagId, path: &ModulePath, ) -> Result<DagId, ModuleResolveError>
Resolve a source inline-DAG/module path to its canonical DagId.
Single-segment paths first name inline DAG children of owner; when
called from an inline DAG body and no nested child exists, they may also
name sibling DAGs under the parent file. Qualified paths use the first
segment as a module alias and append the remaining segments to the alias
target. The returned identity is canonical; source qualifier text is not
carried beyond this resolver boundary.
Sourcepub fn scope(&self, owner: &DagId) -> Option<&ModuleScope>
pub fn scope(&self, owner: &DagId) -> Option<&ModuleScope>
Import scope registered for a module, if any.
IDE consumers use this to map canonical owners back to the module aliases a file spelled in its imports.
Trait Implementations§
Source§impl Clone for ModuleResolver
impl Clone for ModuleResolver
Source§fn clone(&self) -> ModuleResolver
fn clone(&self) -> ModuleResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModuleResolver
impl Debug for ModuleResolver
Source§impl Default for ModuleResolver
impl Default for ModuleResolver
Source§fn default() -> ModuleResolver
fn default() -> ModuleResolver
impl Eq for ModuleResolver
Source§impl PartialEq for ModuleResolver
impl PartialEq for ModuleResolver
Source§fn eq(&self, other: &ModuleResolver) -> bool
fn eq(&self, other: &ModuleResolver) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ModuleResolver
Auto Trait Implementations§
impl Freeze for ModuleResolver
impl RefUnwindSafe for ModuleResolver
impl Send for ModuleResolver
impl Sync for ModuleResolver
impl Unpin for ModuleResolver
impl UnsafeUnpin for ModuleResolver
impl UnwindSafe for ModuleResolver
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.