small refactor

This commit is contained in:
2026-04-15 12:18:40 +02:00
parent 88bf07b913
commit 04087abbdf
4 changed files with 39 additions and 37 deletions
+34
View File
@@ -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
View File
@@ -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,
} => {}
}
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ use std::fs;
use std::path::PathBuf;
use std::process;
use semantic::scope::walk_ast;
use semantic::walk_ast;
fn main() {
let args: Vec<String> = std::env::args().collect();
+2 -5
View File
@@ -1,6 +1,3 @@
struct AddParams {
x: int,
y: int,
function add(a: int, b: int) {
let a = 10;
}
function add(p: AddParams) {}