Refactor NodeIdentity to use unique IDs
The `NodeIdentity` struct has been refactored to use a unique `id` field generated by an atomic counter. This ensures that each `NodeIdentity` instance is distinct, even if it has the same `SourceLocation`. The `location` field is now optional, allowing for anonymous nodes. This change improves the reliability of identity comparisons and provides a more robust way to manage AST node identities.
This commit is contained in:
@@ -134,9 +134,7 @@ impl Environment {
|
||||
let mut purity = self.global_purity.borrow_mut();
|
||||
|
||||
let idx = values.len() as u32;
|
||||
let identity = Rc::new(NodeIdentity {
|
||||
location: SourceLocation { line: 0, col: 0 },
|
||||
});
|
||||
let identity = NodeIdentity::new(SourceLocation { line: 0, col: 0 });
|
||||
names.insert(Symbol::from(name), (idx, identity));
|
||||
types.insert(idx, ty);
|
||||
purity.insert(idx, func.purity);
|
||||
@@ -167,9 +165,7 @@ impl Environment {
|
||||
let mut purity = self.global_purity.borrow_mut();
|
||||
|
||||
let idx = values.len() as u32;
|
||||
let identity = Rc::new(NodeIdentity {
|
||||
location: SourceLocation { line: 0, col: 0 },
|
||||
});
|
||||
let identity = NodeIdentity::new(SourceLocation { line: 0, col: 0 });
|
||||
names.insert(Symbol::from(name), (idx, identity));
|
||||
types.insert(idx, ty);
|
||||
purity.insert(idx, Purity::Pure);
|
||||
|
||||
Reference in New Issue
Block a user