Refactor: Replace optimization level with boolean flag
The optimizer now uses a simple boolean flag (`optimization`) instead of an `optimization_level` (u32). This simplifies the optimizer's logic and makes it easier to enable or disable optimizations. The command-line interface and internal testing have been updated to reflect this change.
This commit is contained in:
@@ -26,7 +26,7 @@ pub struct Environment {
|
||||
pub function_registry: Rc<RefCell<HashMap<u32, BoundNode>>>,
|
||||
pub monomorph_cache: Rc<RefCell<MonoCache>>,
|
||||
pub debug_mode: bool,
|
||||
pub optimization_level: u32,
|
||||
pub optimization: bool,
|
||||
}
|
||||
|
||||
struct EnvFunctionRegistry {
|
||||
@@ -91,7 +91,7 @@ impl Environment {
|
||||
function_registry: Rc::new(RefCell::new(HashMap::new())),
|
||||
monomorph_cache: Rc::new(RefCell::new(HashMap::new())),
|
||||
debug_mode: false,
|
||||
optimization_level: 2,
|
||||
optimization: true,
|
||||
};
|
||||
env.register_stdlib();
|
||||
env
|
||||
@@ -189,7 +189,7 @@ impl Environment {
|
||||
let specialized = self.specialize_node(node);
|
||||
|
||||
// 2. Optimize (Level 1: Cracking, Level 2: Collapsing)
|
||||
let optimizer = Optimizer::new(self.optimization_level)
|
||||
let optimizer = Optimizer::new(self.optimization)
|
||||
.with_globals(self.global_values.clone())
|
||||
.with_purity(self.global_purity.clone());
|
||||
let optimized = optimizer.optimize(specialized);
|
||||
@@ -210,7 +210,7 @@ impl Environment {
|
||||
let global_values = self.global_values.clone();
|
||||
let global_types = self.global_types.clone();
|
||||
let global_purity = self.global_purity.clone();
|
||||
let opt_level = self.optimization_level;
|
||||
let optimization = self.optimization;
|
||||
|
||||
let compiler = Rc::new(
|
||||
move |func_template: BoundNode,
|
||||
@@ -237,7 +237,7 @@ impl Environment {
|
||||
let specialized_ast = sub_specializer.specialize(retyped_ast);
|
||||
|
||||
// 3. Optimize (Phase 2: Cracking & Folding)
|
||||
let optimizer = Optimizer::new(opt_level)
|
||||
let optimizer = Optimizer::new(optimization)
|
||||
.with_globals(global_values.clone())
|
||||
.with_purity(global_purity.clone());
|
||||
let optimized_ast = optimizer.optimize(specialized_ast);
|
||||
|
||||
Reference in New Issue
Block a user