feat(mir): Phase 136 Step 2/7 - CoreContext extraction complete

Extract core ID generation fields from MirBuilder to improve organization:
- value_gen: ValueIdGenerator
- block_gen: BasicBlockIdGenerator
- next_binding_id: u32 (Phase 74)
- temp_slot_counter: u32
- debug_join_counter: u32

Implementation:
- Created src/mir/builder/core_context.rs (215 lines)
- Added core_ctx field to MirBuilder as SSOT
- Deprecated legacy fields with backward compat
- ID allocation methods use core_ctx and sync legacy fields
- Added next_block_id() helper, replaced 30+ block_gen.next() calls

Testing:
- cargo build --release: SUCCESS (193 warnings expected)
- cargo test --release --lib: 1004/1004 PASS (+7 tests)
- phase135_trim_mir_verify.sh: PASS
- phase132_exit_phi_parity.sh: 3/3 PASS

Progress: 2/7 Context extractions complete (TypeContext + CoreContext)

🤖 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-15 20:10:36 +09:00
parent 076f193f76
commit 81d79161e4
12 changed files with 325 additions and 61 deletions

View File

@ -340,9 +340,9 @@ impl super::MirBuilder {
let lhs_val = self.pin_to_slot(lhs_val0, "@sc_lhs")?;
// Prepare blocks
let then_block = self.block_gen.next();
let else_block = self.block_gen.next();
let merge_block = self.block_gen.next();
let then_block = self.next_block_id();
let else_block = self.next_block_id();
let merge_block = self.next_block_id();
// Branch on LHS truthiness (runtime to_bool semantics in interpreter/LLVM)
let mut lhs_cond = self.local_cond(lhs_val);
@ -371,9 +371,9 @@ impl super::MirBuilder {
// OR: then → constant true
let then_value_raw = if is_and {
// Reduce arbitrary RHS to bool by branching on its truthiness and returning consts
let rhs_true = self.block_gen.next();
let rhs_false = self.block_gen.next();
let rhs_join = self.block_gen.next();
let rhs_true = self.next_block_id();
let rhs_false = self.next_block_id();
let rhs_join = self.next_block_id();
let rhs_val = self.build_expression(right.clone())?;
let mut rhs_cond = self.local_cond(rhs_val);
crate::mir::builder::ssa::local::finalize_branch_cond(self, &mut rhs_cond);
@ -425,9 +425,9 @@ impl super::MirBuilder {
let f_id = crate::mir::builder::emission::constant::emit_bool(self, false);
f_id
} else {
let rhs_true = self.block_gen.next();
let rhs_false = self.block_gen.next();
let rhs_join = self.block_gen.next();
let rhs_true = self.next_block_id();
let rhs_false = self.next_block_id();
let rhs_join = self.next_block_id();
let rhs_val = self.build_expression(right)?;
let mut rhs_cond = self.local_cond(rhs_val);
crate::mir::builder::ssa::local::finalize_branch_cond(self, &mut rhs_cond);