Skip to content

Commit 4089de7

Browse files
committed
#5 work on Compiler2
1 parent f10ca2f commit 4089de7

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/compiler.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,21 @@ impl Compiler2 {
227227
}
228228

229229
pub fn check(&mut self) -> bool {
230+
231+
let mut decls = vec![];
232+
for tree in &self.ast {
233+
decls.append(&mut tree.decls.clone());
234+
}
235+
236+
self.decls = DeclTable::new(decls);
237+
230238
let mut checker = Checker::new();
231239

240+
println!("Checking program...");
241+
232242
for tree in &self.ast {
233243
for decl in &tree.decls {
244+
println!("Checking decl: {:?}...", decl);
234245
checker.check_decl(decl, &self.decls);
235246
}
236247
}
@@ -322,13 +333,22 @@ impl Default for Compiler {
322333
mod tests {
323334

324335
fn jit(code: &str) {
336+
337+
let mut compiler = crate::Compiler2::new();
338+
let paths = vec![String::from(".")];
339+
340+
compiler.parse(code.into(), &paths[0]);
341+
compiler.check();
342+
// compiler.jit();
343+
344+
/*
325345
let mut compiler = crate::Compiler::new();
326346
let paths = vec![String::from(".")];
327347

328348
compiler.update_path(&paths[0], code.into());
329349
compiler.set_paths(paths);
330350

331-
compiler.jit();
351+
compiler.jit();*/
332352
}
333353

334354
#[test]

0 commit comments

Comments
 (0)