Refactor UsageInfo and SubstitutionMap
This commit refactors the `UsageInfo` struct to use a single `HashSet<Address>` for both used and assigned addresses, simplifying the logic. It also updates the `SubstitutionMap` to use a similar approach for tracking assigned values. Key changes include: - `UsageInfo` now has `used` and `assigned` fields of type `HashSet<Address>`. - `SubstitutionMap`'s `add_local`, `add_global`, `add_upvalue`, `remove_local`, `remove_global`, and `remove_upvalue` methods have been replaced with a generic `add_value` and `remove_value` that operate on `Address`. - The `Optimizer`'s `collect_pattern_usage` and `visit_node` methods have been updated to use the new `UsageInfo` and `SubstitutionMap` APIs. - `Get` and `Set` nodes now use `sub.map_address` to transform addresses based on the current substitution.
This commit is contained in:
@@ -237,7 +237,9 @@ impl<T> BoundKind<T> {
|
||||
BoundKind::Constant(v) => format!("CONST({})", v),
|
||||
BoundKind::Get { addr, name } => format!("GET({}, {:?})", name.name, addr),
|
||||
BoundKind::Set { addr, .. } => format!("SET({:?})", addr),
|
||||
BoundKind::Define { name, addr, kind, .. } => {
|
||||
BoundKind::Define {
|
||||
name, addr, kind, ..
|
||||
} => {
|
||||
let k_str = match kind {
|
||||
DeclarationKind::Variable => "VAR",
|
||||
DeclarationKind::Parameter => "PARAM",
|
||||
|
||||
Reference in New Issue
Block a user