Refactor: Use root_purity instead of global_purity

This commit refactors the purity analysis from using a
`HashMap<GlobalIdx, Purity>` to a `Vec<Purity>` indexed by
`GlobalIdx.0`.

This change simplifies the data structure and makes purity lookups more
efficient. The `Binder`'s `globals` field has also been removed as it
was not being used.
This commit is contained in:
Michael Schimmel
2026-03-12 16:57:06 +01:00
parent dcb7685d29
commit bf86c76bb6
8 changed files with 123 additions and 131 deletions
+3 -4
View File
@@ -627,7 +627,6 @@ mod tests {
use crate::ast::compiler::Binder;
use crate::ast::parser::Parser;
use crate::ast::types::{Object, Value};
use std::cell::RefCell;
struct SimpleEvaluator;
impl MacroEvaluator for SimpleEvaluator {
@@ -783,7 +782,7 @@ mod tests {
let mut diag = crate::ast::diagnostics::Diagnostics::new();
// fixed_scope_idx = 0 means scope 0 is frozen (Global)
let result = Binder::bind_root(initial_scopes, 1, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
let result = Binder::bind_root(initial_scopes, 1, 0, &expanded, &mut diag);
assert!(
result.is_ok(),
"Should find global '*' Error: {:?}",
@@ -807,7 +806,7 @@ mod tests {
let expanded = expander.expand(untyped).unwrap();
let mut diag = crate::ast::diagnostics::Diagnostics::new();
let result = Binder::bind_root(vec![], 0, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
let result = Binder::bind_root(vec![], 0, 0, &expanded, &mut diag);
assert!(result.is_ok(), "Hygiene failed: {:?}", result.err());
}
@@ -827,7 +826,7 @@ mod tests {
let expanded = expander.expand(untyped).unwrap();
let mut diag = crate::ast::diagnostics::Diagnostics::new();
let result = Binder::bind_root(vec![], 0, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
let result = Binder::bind_root(vec![], 0, 0, &expanded, &mut diag);
assert!(
result.is_ok(),
"Explicit Hygiene with Backticks failed: {:?}",