feat(joinir): Phase 220-D loop condition variable support complete
Modified extract_loop_condition() to use ConditionEnv for variable lookup: - Now returns ValueId instead of i64 for loop limit - Uses lower_value_expression() for both literals and variables - Integrated ConditionEnvBuilder in Pattern 3 if-sum path This enables realistic loop patterns like `loop(i < len)` in if-sum. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -112,11 +112,31 @@ impl MirBuilder {
|
||||
"[cf_loop/pattern3] if-sum pattern detected but no if statement found".to_string()
|
||||
})?;
|
||||
|
||||
// Call AST-based if-sum lowerer
|
||||
// Phase 220-D: Build ConditionEnv for variable resolution
|
||||
use super::condition_env_builder::ConditionEnvBuilder;
|
||||
let loop_var_name = ctx.loop_var_name.clone();
|
||||
let loop_var_id = ctx.loop_var_id;
|
||||
|
||||
let (cond_env, condition_bindings, _loop_var_join_id) =
|
||||
ConditionEnvBuilder::build_for_break_condition_v2(
|
||||
condition,
|
||||
&loop_var_name,
|
||||
&self.variable_map,
|
||||
loop_var_id,
|
||||
&mut join_value_space,
|
||||
)?;
|
||||
|
||||
eprintln!("[pattern3/if-sum] Phase 220-D: ConditionEnv has {} bindings", condition_bindings.len());
|
||||
for binding in &condition_bindings {
|
||||
eprintln!(" '{}': HOST {:?} → JoinIR {:?}", binding.name, binding.host_value, binding.join_value);
|
||||
}
|
||||
|
||||
// Call AST-based if-sum lowerer with ConditionEnv
|
||||
let (join_module, fragment_meta) = lower_if_sum_pattern(
|
||||
condition,
|
||||
if_stmt,
|
||||
body,
|
||||
&cond_env,
|
||||
&mut join_value_space,
|
||||
)?;
|
||||
|
||||
@ -174,8 +194,10 @@ impl MirBuilder {
|
||||
);
|
||||
|
||||
// Phase 215-2: Pass expr_result to boundary
|
||||
// Phase 220-D: Pass condition_bindings for variable remapping
|
||||
let mut boundary_builder = JoinInlineBoundaryBuilder::new()
|
||||
.with_inputs(join_inputs, host_inputs)
|
||||
.with_condition_bindings(condition_bindings) // Phase 220-D: Map condition-only vars
|
||||
.with_exit_bindings(exit_bindings)
|
||||
.with_loop_var_name(Some(ctx.loop_var_name.clone()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user