lang: smol module tree things and details
This commit is contained in:
parent
7bc603f7e7
commit
1a533eb788
4 changed files with 12 additions and 15 deletions
|
@ -58,11 +58,4 @@ impl World {
|
|||
module_tree,
|
||||
})
|
||||
}
|
||||
|
||||
// fn parse_mod_tree(files: &mut HashMap<PathBuf, SourceFile>)
|
||||
}
|
||||
|
||||
// struct SourceFile {
|
||||
// tree: SyntaxNode,
|
||||
// items: Vec<TopLevelItem>,
|
||||
// }
|
||||
|
|
|
@ -18,7 +18,7 @@ use super::{
|
|||
};
|
||||
|
||||
pub struct ModuleTree {
|
||||
modules: Rc<HashMap<String, Module>>,
|
||||
modules: Rc<HashMap<String, Rc<Module>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -71,7 +71,7 @@ impl ModuleParsingContext {
|
|||
&self,
|
||||
node: &SyntaxNode,
|
||||
name: Option<String>,
|
||||
) -> HashMap<String, Module> {
|
||||
) -> HashMap<String, Rc<Module>> {
|
||||
let mut ctx = self.clone();
|
||||
if let Some(name) = name {
|
||||
ctx.push_cur_path(name)
|
||||
|
@ -79,13 +79,13 @@ impl ModuleParsingContext {
|
|||
node.children()
|
||||
.filter_map(Mod::cast)
|
||||
.filter_map(|m| match Module::parse_mod(m, self.clone()) {
|
||||
Ok(module) => Some((module.name(), module)),
|
||||
Ok(module) => Some((module.name(), Rc::new(module))),
|
||||
Err(error) => {
|
||||
self.errors.borrow_mut().push(error);
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<HashMap<String, Module>>()
|
||||
.collect::<HashMap<String, Rc<Module>>>()
|
||||
}
|
||||
|
||||
fn dissolve(self) -> (HashMap<PathBuf, SourceFile>, Vec<Error>) {
|
||||
|
@ -118,8 +118,8 @@ pub struct Module {
|
|||
path: Vec<String>,
|
||||
name: String,
|
||||
kind: ModuleKind,
|
||||
children: Rc<HashMap<String, Module>>,
|
||||
parent: Option<Arc<Module>>,
|
||||
children: Rc<HashMap<String, Rc<Module>>>,
|
||||
parent: Option<Rc<Module>>,
|
||||
}
|
||||
|
||||
impl Module {
|
||||
|
@ -214,7 +214,7 @@ impl Module {
|
|||
}
|
||||
}
|
||||
|
||||
fn print_tree(name: &str, children: Rc<HashMap<String, Module>>, level: u32) {
|
||||
fn print_tree(name: &str, children: Rc<HashMap<String, Rc<Module>>>, level: u32) {
|
||||
const INDENT_STR: &str = " ";
|
||||
|
||||
for _ in 0..level {
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
mod meow;
|
||||
|
||||
def broken
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
mod mrawr {}
|
||||
mod mrow {}
|
||||
mod mrow {
|
||||
def gay = ;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue