-
-
Save matklad/145c88131282e8392e64d088ee8a50e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Abstract import resolution | |
use std::hash::Hash; | |
use ra_arena::{Arena, Idx}; | |
use rustc_hash::FxHashMap; | |
type Name = hir_expand::name::Name; | |
type Def = u32; | |
struct Scopes { | |
scopes: Arena<ScopeData>, | |
links: Vec<Link>, | |
} | |
type Scope = Idx<ScopeData>; | |
struct ScopeData { | |
defs: PerNs<FxHashMap<Name, Def>>, | |
} | |
struct Import { | |
anchor: ImportAnchor, | |
path: Vec<Name>, | |
what: ImportSpec, | |
} | |
enum ImportAnchor { | |
None, | |
Ancestor(u32), | |
Crate, | |
Abs, | |
} | |
enum ImportSpec { | |
All, | |
Name { name: Name, alias: Option<Option<Name>> }, | |
} | |
struct PerNs<T> { | |
types: T, | |
values: T, | |
macros: T, | |
} | |
struct Resolver { | |
scopes: Scopes, | |
} | |
struct Link { | |
from: Scope, | |
to: Scope, | |
what: ImportSpec, | |
} | |
impl Resolver { | |
fn add_scope() -> Scope { | |
todo!() | |
} | |
fn add_def(&mut self, scope: Scope, name: Name, def: PerNs<Def>) { | |
todo!() | |
} | |
fn add_import(&mut self, scope: Scope, import: Import) { | |
todo!() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment