feat: Add type checking to the compiler
Introduces the `TypeChecker` struct and its associated `TypeContext` for performing static type analysis on the abstract syntax tree. This change includes: - A new `type_checker.rs` module. - Integration of `TypeChecker` into the `Environment::compile` method. - Updates to `Environment` to manage global types. - Renaming `bound_nodes.rs`'s `BoundNode` to `TypedNode` to reflect its type-checked nature. - Refinements in binder and macro expansion to accommodate type information.
This commit is contained in:
@@ -80,8 +80,10 @@ mod tests {
|
||||
let mut binder = Binder::new(globals.clone());
|
||||
let bound_ast = binder.bind(&ast).expect("Failed to bind");
|
||||
|
||||
// BRIDGE: Binder -> VM requires a TypedNode
|
||||
let typed_ast = crate::ast::environment::dummy_type_check(bound_ast);
|
||||
// Use the real TypeChecker instead of the dummy placeholder
|
||||
let global_types = Rc::new(RefCell::new(std::collections::HashMap::new()));
|
||||
let checker = crate::ast::compiler::TypeChecker::new(global_types);
|
||||
let typed_ast = checker.check(bound_ast).expect("Type check failed");
|
||||
|
||||
let vm_globals = Rc::new(RefCell::new(Vec::new()));
|
||||
let mut vm = VM::new(vm_globals);
|
||||
|
||||
Reference in New Issue
Block a user