Add example and refine local inlining
Add a new example file `examples/def_local_inlining.myc` to demonstrate and test local inlining. Refine the optimizer to handle local inlining more robustly by: - Passing a `SubstitutionMap` to `visit_node` to track local variable substitutions. - Enabling constant propagation for local variables by checking `sub.locals` in `BoundKind::Get`. - Updating `BoundKind::DefLocal` and `BoundKind::Set` to maintain the substitution map for local variables. - Adjusting `try_beta_reduce` to use the optimizer's `visit_node` with the substitution map for inlining. - Re-indexing upvalues correctly when inlining captured variables into lambdas.
This commit is contained in:
+4
-1
@@ -52,7 +52,10 @@ pub fn run_functional_tests_with_level(level: u32) -> Vec<TestResult> {
|
||||
results.push(TestResult {
|
||||
name,
|
||||
success: false,
|
||||
message: format!("Level {}: Expected {}, got {}", level, expected, val_str),
|
||||
message: format!(
|
||||
"Level {}: Expected {}, got {}",
|
||||
level, expected, val_str
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user