mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-11-05 15:26:24 +01:00
lang: smol module tree things and details
This commit is contained in:
parent
7bc603f7e7
commit
1a533eb788
|
@ -58,11 +58,4 @@ impl World {
|
||||||
module_tree,
|
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 {
|
pub struct ModuleTree {
|
||||||
modules: Rc<HashMap<String, Module>>,
|
modules: Rc<HashMap<String, Rc<Module>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -71,7 +71,7 @@ impl ModuleParsingContext {
|
||||||
&self,
|
&self,
|
||||||
node: &SyntaxNode,
|
node: &SyntaxNode,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
) -> HashMap<String, Module> {
|
) -> HashMap<String, Rc<Module>> {
|
||||||
let mut ctx = self.clone();
|
let mut ctx = self.clone();
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
ctx.push_cur_path(name)
|
ctx.push_cur_path(name)
|
||||||
|
@ -79,13 +79,13 @@ impl ModuleParsingContext {
|
||||||
node.children()
|
node.children()
|
||||||
.filter_map(Mod::cast)
|
.filter_map(Mod::cast)
|
||||||
.filter_map(|m| match Module::parse_mod(m, self.clone()) {
|
.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) => {
|
Err(error) => {
|
||||||
self.errors.borrow_mut().push(error);
|
self.errors.borrow_mut().push(error);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<HashMap<String, Module>>()
|
.collect::<HashMap<String, Rc<Module>>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dissolve(self) -> (HashMap<PathBuf, SourceFile>, Vec<Error>) {
|
fn dissolve(self) -> (HashMap<PathBuf, SourceFile>, Vec<Error>) {
|
||||||
|
@ -118,8 +118,8 @@ pub struct Module {
|
||||||
path: Vec<String>,
|
path: Vec<String>,
|
||||||
name: String,
|
name: String,
|
||||||
kind: ModuleKind,
|
kind: ModuleKind,
|
||||||
children: Rc<HashMap<String, Module>>,
|
children: Rc<HashMap<String, Rc<Module>>>,
|
||||||
parent: Option<Arc<Module>>,
|
parent: Option<Rc<Module>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 = " ";
|
const INDENT_STR: &str = " ";
|
||||||
|
|
||||||
for _ in 0..level {
|
for _ in 0..level {
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
mod meow;
|
mod meow;
|
||||||
|
|
||||||
|
def broken
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
mod mrawr {}
|
mod mrawr {}
|
||||||
mod mrow {}
|
mod mrow {
|
||||||
|
def gay = ;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue