small refactor
This commit is contained in:
@@ -1,3 +1,37 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::scope::{LocalScope, Scope};
|
||||
|
||||
pub mod hir;
|
||||
pub mod scope;
|
||||
pub mod top_level;
|
||||
|
||||
pub fn walk_ast(top_scope: Arc<Scope>, tl: &mut Vec<parser::ast::TopLevel>) {
|
||||
for tl in tl {
|
||||
match tl {
|
||||
parser::ast::TopLevel::Import(_) => unimplemented!(),
|
||||
|
||||
parser::ast::TopLevel::FunctionDecl {
|
||||
export,
|
||||
name,
|
||||
params,
|
||||
return_type,
|
||||
body,
|
||||
} => {
|
||||
let scope = LocalScope::new(top_scope.clone());
|
||||
|
||||
scope.with_params(params);
|
||||
|
||||
scope.with_block(body);
|
||||
|
||||
println!("{:?}", scope);
|
||||
}
|
||||
|
||||
parser::ast::TopLevel::StructDecl {
|
||||
export,
|
||||
name,
|
||||
fields,
|
||||
} => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-30
@@ -61,6 +61,7 @@ impl LocalScope {
|
||||
for statement in &mut block.0 {
|
||||
match statement {
|
||||
Statement::Block(b) => self.clone().with_block(b),
|
||||
Statement::VarDecl { kind, name, init } => unimplemented!(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -85,33 +86,3 @@ impl LocalScope {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_ast(top_scope: Arc<Scope>, tl: &mut Vec<parser::ast::TopLevel>) {
|
||||
for tl in tl {
|
||||
match tl {
|
||||
parser::ast::TopLevel::Import(_) => unimplemented!(),
|
||||
|
||||
parser::ast::TopLevel::FunctionDecl {
|
||||
export,
|
||||
name,
|
||||
params,
|
||||
return_type,
|
||||
body,
|
||||
} => {
|
||||
let scope = LocalScope::new(top_scope.clone());
|
||||
|
||||
scope.with_params(params);
|
||||
|
||||
scope.with_block(body);
|
||||
|
||||
println!("{:?}", scope);
|
||||
}
|
||||
|
||||
parser::ast::TopLevel::StructDecl {
|
||||
export,
|
||||
name,
|
||||
fields,
|
||||
} => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user