Refactor address types to use newtype wrappers
This commit introduces newtype wrappers for `LocalSlot`, `UpvalueIdx`, and `GlobalIdx` to improve type safety and clarity. These wrappers replace direct use of `u32` for indices, making the code more robust and easier to understand. The changes include: - Defining `LocalSlot`, `UpvalueIdx`, and `GlobalIdx` structs. - Implementing `Display` for these new types to provide user-friendly output. - Updating the `Address` enum to use these new types. - Modifying various compiler components (analyzer, binder, optimizer, type checker, environment, VM) to use the new types. - Adjusting tests to accommodate the changes.
This commit is contained in:
@@ -716,8 +716,11 @@ mod tests {
|
||||
global_names.insert(
|
||||
Symbol::from("*"),
|
||||
(
|
||||
0,
|
||||
crate::ast::types::NodeIdentity::new(crate::ast::types::SourceLocation { line: 0, col: 0 }),
|
||||
crate::ast::compiler::bound_nodes::GlobalIdx(0),
|
||||
crate::ast::types::NodeIdentity::new(crate::ast::types::SourceLocation {
|
||||
line: 0,
|
||||
col: 0,
|
||||
}),
|
||||
),
|
||||
);
|
||||
let globals = Rc::new(RefCell::new(global_names));
|
||||
|
||||
Reference in New Issue
Block a user