diff --git a/src/mir/builder.rs b/src/mir/builder.rs index 094b4021..2afc868b 100644 --- a/src/mir/builder.rs +++ b/src/mir/builder.rs @@ -91,15 +91,6 @@ pub struct MirBuilder { /// Direct field access for backward compatibility (migration in progress). pub(super) core_ctx: core_context::CoreContext, - /// [DEPRECATED] Value ID generator - /// Phase 136: Moved to core_ctx.value_gen (backward compat wrapper) - #[deprecated(note = "Use core_ctx.value_gen instead")] - pub(super) value_gen: ValueIdGenerator, - - /// [DEPRECATED] Basic block ID generator - /// Phase 136: Moved to core_ctx.block_gen (backward compat wrapper) - #[deprecated(note = "Use core_ctx.block_gen instead")] - pub(super) block_gen: BasicBlockIdGenerator, /// [DEPRECATED] 箱理論: Static boxコンパイル時のコンテキスト分離 /// Phase 136 Step 7/7: Moved to comp_ctx.compilation_context (backward compat wrapper) @@ -259,11 +250,6 @@ pub struct MirBuilder { #[deprecated(note = "Use comp_ctx.reserved_value_ids instead")] pub(super) reserved_value_ids: HashSet, - /// [DEPRECATED] Phase 74: BindingId allocation counter (parallel to ValueId) - /// Phase 136: Moved to core_ctx.next_binding_id (backward compat wrapper) - #[deprecated(note = "Use core_ctx.next_binding_id instead")] - pub next_binding_id: u32, - /// [DEPRECATED] Phase 74: BindingId mapping for lexical variable bindings /// Phase 136: Moved to binding_ctx.binding_map (backward compat wrapper) #[deprecated(note = "Use binding_ctx.binding_map instead")] @@ -301,10 +287,6 @@ pub struct MirBuilder { pub(super) cleanup_allow_return: bool, pub(super) cleanup_allow_throw: bool, - /// [DEPRECATED] Internal counter for temporary pin slots (block-crossing ephemeral values) - /// Phase 136: Moved to core_ctx.temp_slot_counter (backward compat wrapper) - #[deprecated(note = "Use core_ctx.temp_slot_counter instead")] - temp_slot_counter: u32, /// If true, skip entry materialization of pinned slots on the next start_new_block call. suppress_pin_entry_copy_next: bool, @@ -315,10 +297,6 @@ pub struct MirBuilder { /// Phase 136: Moved to scope_ctx.debug_scope_stack (backward compat wrapper) #[deprecated(note = "Use scope_ctx.debug_scope_stack instead")] debug_scope_stack: Vec, - /// [DEPRECATED] Monotonic counter for region IDs (deterministic across a run). - /// Phase 136: Moved to core_ctx.debug_join_counter (backward compat wrapper) - #[deprecated(note = "Use core_ctx.debug_join_counter instead")] - debug_join_counter: u32, /// Local SSA cache: ensure per-block materialization for critical operands (e.g., recv) /// Key: (bb, original ValueId, kind) -> local ValueId @@ -374,10 +352,6 @@ impl MirBuilder { // Phase 136 Step 2/7: Core context (new SSOT) core_ctx, - // Legacy fields (kept for backward compatibility, synced with core_ctx) - value_gen: ValueIdGenerator::new(), - block_gen: BasicBlockIdGenerator::new(), - compilation_context: None, // 箱理論: デフォルトは従来モード type_ctx: type_context::TypeContext::new(), // Phase 136: Type context scope_ctx: scope_context::ScopeContext::new(), // Phase 136 Step 3/7: Scope context @@ -408,7 +382,6 @@ impl MirBuilder { fn_body_ast: None, // Phase 200-C: Initialize to None reserved_value_ids: HashSet::new(), // Phase 201-A: Initialize to empty - next_binding_id: 0, // Phase 74: Initialize BindingId counter (legacy) binding_map: BTreeMap::new(), // Phase 74: Initialize BindingId mapping loop_header_stack: Vec::new(), @@ -422,12 +395,10 @@ impl MirBuilder { in_cleanup_block: false, cleanup_allow_return: false, cleanup_allow_throw: false, - temp_slot_counter: 0, // Legacy (synced with core_ctx) suppress_pin_entry_copy_next: false, // Debug scope context debug_scope_stack: Vec::new(), - debug_join_counter: 0, // Legacy (synced with core_ctx) local_ssa_map: HashMap::new(), schedule_mat_map: HashMap::new(), @@ -549,12 +520,9 @@ impl MirBuilder { /// // next_value_id() -> ValueId(20) /// // } /// ``` - #[allow(deprecated)] pub fn allocate_binding_id(&mut self) -> super::BindingId { - // Phase 136 Step 2/7: Use core_ctx as SSOT, sync legacy field - let id = self.core_ctx.next_binding(); - self.next_binding_id = self.core_ctx.next_binding_id; - id + // Phase 136 Step 2/7 + Phase 2-2: Use core_ctx as SSOT (no sync needed) + self.core_ctx.next_binding() } // ---- Hint helpers (no-op by default) ---- @@ -576,12 +544,9 @@ impl MirBuilder { // Debug scope helpers (region_id for DebugHub events) // ---------------------- #[inline] - #[allow(deprecated)] pub(crate) fn debug_next_join_id(&mut self) -> u32 { - // Phase 136 Step 2/7: Use core_ctx as SSOT, sync legacy field - let id = self.core_ctx.next_debug_join(); - self.debug_join_counter = self.core_ctx.debug_join_counter; - id + // Phase 136 Step 2/7 + Phase 2-2: Use core_ctx as SSOT (no sync needed) + self.core_ctx.next_debug_join() } #[inline] @@ -1317,7 +1282,7 @@ mod binding_id_tests { #[allow(deprecated)] fn test_binding_map_initialization() { let builder = MirBuilder::new(); - assert_eq!(builder.next_binding_id, 0); + assert_eq!(builder.core_ctx.next_binding_id, 0); // Phase 136 Step 4/7: Check both binding_ctx (SSOT) and legacy field assert!(builder.binding_ctx.is_empty()); assert!(builder.binding_map.is_empty()); @@ -1333,7 +1298,7 @@ mod binding_id_tests { assert_eq!(bid0.raw(), 0); assert_eq!(bid1.raw(), 1); assert_eq!(bid2.raw(), 2); - assert_eq!(builder.next_binding_id, 3); + assert_eq!(builder.core_ctx.next_binding_id, 3); } #[test] diff --git a/src/mir/builder/utils.rs b/src/mir/builder/utils.rs index 7176fa9e..cca70df1 100644 --- a/src/mir/builder/utils.rs +++ b/src/mir/builder/utils.rs @@ -41,10 +41,8 @@ impl super::MirBuilder { let candidate = if let Some(ref mut f) = self.current_function { f.next_value_id() // Function context } else { - // Phase 136 Step 2/7: Use core_ctx as SSOT, sync legacy field - let id = self.core_ctx.next_value(); - self.value_gen = self.core_ctx.value_gen.clone(); - id + // Phase 136 Step 2/7 + Phase 2-2: Use core_ctx as SSOT (no sync needed) + self.core_ctx.next_value() }; // Phase 201-A: Skip reserved PHI dst ValueIds @@ -60,13 +58,10 @@ impl super::MirBuilder { /// Allocate a new BasicBlockId /// - /// Phase 136 Step 2/7: Uses core_ctx as SSOT, syncs legacy field. + /// Phase 136 Step 2/7 + Phase 2-2: Uses core_ctx as SSOT (no sync needed). #[inline] - #[allow(deprecated)] pub(crate) fn next_block_id(&mut self) -> super::BasicBlockId { - let id = self.core_ctx.next_block(); - self.block_gen = self.core_ctx.block_gen.clone(); - id + self.core_ctx.next_block() } // ---- LocalSSA convenience (readability helpers) ---- @@ -442,13 +437,13 @@ impl super::MirBuilder { v: super::ValueId, hint: &str, ) -> Result { - self.temp_slot_counter = self.temp_slot_counter.wrapping_add(1); - let slot_name = format!("__pin${}${}", self.temp_slot_counter, hint); + let slot_id = self.core_ctx.next_temp_slot(); + let slot_name = format!("__pin${}${}", slot_id, hint); // Phase 25.1b: Use function-local ID allocator to avoid SSA verification failures let dst = if let Some(ref mut f) = self.current_function { f.next_value_id() // Function context: use local ID } else { - self.value_gen.next() // Module context: use global ID + self.core_ctx.next_value() // Module context: use core_ctx SSOT }; self.emit_instruction(super::MirInstruction::Copy { dst, src: v })?; if super::utils::builder_debug_enabled() @@ -479,7 +474,7 @@ impl super::MirBuilder { let dst = if let Some(ref mut f) = self.current_function { f.next_value_id() // Function context: use local ID } else { - self.value_gen.next() // Module context: use global ID + self.core_ctx.next_value() // Module context: use core_ctx SSOT }; self.emit_instruction(super::MirInstruction::Copy { dst, src: v })?; // Propagate metadata (type/origin) from source to the new local copy diff --git a/src/mir/loop_api.rs b/src/mir/loop_api.rs index a5b0b6e8..68ba09ae 100644 --- a/src/mir/loop_api.rs +++ b/src/mir/loop_api.rs @@ -83,7 +83,7 @@ pub fn build_simple_loop( // === Legacy wiring: implement LoopBuilderApi for mir::builder::MirBuilder === impl LoopBuilderApi for super::builder::MirBuilder { fn new_block(&mut self) -> BasicBlockId { - self.block_gen.next() + self.core_ctx.next_block() } fn current_block(&self) -> Result { self.current_block diff --git a/src/mir/utils/phi_helpers.rs b/src/mir/utils/phi_helpers.rs index 75574a72..c073a9d1 100644 --- a/src/mir/utils/phi_helpers.rs +++ b/src/mir/utils/phi_helpers.rs @@ -66,7 +66,7 @@ impl MirBuilder { let phi_val = if let Some(ref mut f) = self.current_function { f.next_value_id() // Function context: use local ID allocator } else { - self.value_gen.next() // Module context: use global ID allocator + self.core_ctx.next_value() // Module context: use core_ctx SSOT }; // 統一された挿入ロジック(既存パターンと完全互換)