feat(joinir): Phase 202-B Pattern 3 uses JoinValueSpace

Replace sequential value_counter (0u32) with JoinValueSpace allocator
in Pattern 3 (If-PHI) lowering for unified ValueId management.

Changes:
- loop_with_if_phi_minimal.rs: Replace value_counter with join_value_space.alloc_local()
- pattern3_with_if_phi.rs: Create JoinValueSpace and pass to lowerer
- loop_patterns/with_if_phi.rs: Update legacy wrapper to use JoinValueSpace

Benefits:
- Consistent with Pattern 2 implementation (Phase 201)
- Prevents ValueId collision in Local region (1000+)
- Clean separation: Param region (100-999) vs Local region (1000+)

Test status:
- All unit tests pass (5/5)
- E2E tests pass: loop_if_phi.hako, loop_if_phi_continue.hako

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-09 19:14:01 +09:00
parent 6e778948db
commit 98e81b2650
4 changed files with 265 additions and 11 deletions

View File

@ -101,8 +101,12 @@ impl MirBuilder {
// Phase 195: Use unified trace
trace::trace().varmap("pattern3_start", &self.variable_map);
// Phase 202-B: Create JoinValueSpace for unified ValueId allocation
use crate::mir::join_ir::lowering::join_value_space::JoinValueSpace;
let mut join_value_space = JoinValueSpace::new();
// Call Pattern 3 lowerer with preprocessed scope
let join_module = match lower_loop_with_if_phi_pattern(ctx.loop_scope) {
let join_module = match lower_loop_with_if_phi_pattern(ctx.loop_scope, &mut join_value_space) {
Some(module) => module,
None => {
// Phase 195: Use unified trace