Refactor: Pass global names to Binder
The `Binder` struct now accepts a `Rc<RefCell<HashMap<Symbol, (GlobalIdx, Identity)>>>` for global names. This allows the binder to directly access and manage global symbols during the binding process, simplifying the logic and improving efficiency. Additionally, `CompilerScope` now implements `Default`, and a type alias `BindingResult` has been introduced for clarity. The `bind_root` function signature has been updated to accept the `globals` argument.
This commit is contained in:
@@ -783,7 +783,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, &expanded, &mut diag);
|
||||
let result = Binder::bind_root(initial_scopes, 1, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Should find global '*' Error: {:?}",
|
||||
@@ -807,7 +807,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, &expanded, &mut diag);
|
||||
let result = Binder::bind_root(vec![], 0, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
|
||||
assert!(result.is_ok(), "Hygiene failed: {:?}", result.err());
|
||||
}
|
||||
|
||||
@@ -827,7 +827,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, &expanded, &mut diag);
|
||||
let result = Binder::bind_root(vec![], 0, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Explicit Hygiene with Backticks failed: {:?}",
|
||||
|
||||
Reference in New Issue
Block a user