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 hir;
|
||||||
pub mod scope;
|
pub mod scope;
|
||||||
pub mod top_level;
|
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 {
|
for statement in &mut block.0 {
|
||||||
match statement {
|
match statement {
|
||||||
Statement::Block(b) => self.clone().with_block(b),
|
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
@@ -2,7 +2,7 @@ use std::fs;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use semantic::scope::walk_ast;
|
use semantic::walk_ast;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
|||||||
+2
-5
@@ -1,6 +1,3 @@
|
|||||||
struct AddParams {
|
function add(a: int, b: int) {
|
||||||
x: int,
|
let a = 10;
|
||||||
y: int,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function add(p: AddParams) {}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user