Refactor Optimizer to use Folder

Extract common AST manipulation and folding logic into a new Folder
struct. This improves code organization and reusability. The Optimizer
now delegates these tasks to the Folder.
This commit is contained in:
Michael Schimmel
2026-02-25 19:57:00 +01:00
parent d3d1497c02
commit 7f64e7e6ea
4 changed files with 112 additions and 83 deletions
@@ -143,6 +143,7 @@ impl UsageInfo {
}
}
#[derive(Default)]
pub struct SubstitutionMap {
pub values: HashMap<Address, Value>,
pub ast_substitutions: HashMap<Address, AnalyzedNode>,
@@ -155,15 +156,7 @@ pub struct SubstitutionMap {
impl SubstitutionMap {
pub fn new() -> Self {
Self {
values: HashMap::new(),
ast_substitutions: HashMap::new(),
slot_mapping: HashMap::new(),
assigned: HashSet::new(),
next_slot: 0,
used: HashSet::new(),
captured_slots: HashSet::new(),
}
Self::default()
}
pub fn add_ast_substitution(&mut self, addr: Address, node: AnalyzedNode) {