feat(joinir): Phase 61-6.1 Delete set_if_context thin wrapper (-26 lines)
Phase 61-6.1 実装完了: set_if_context() 薄いラッパー削除 ## 変更内容 ### phi_builder_box.rs - ✅ if_context フィールドを pub 化(L75) - ✅ set_if_context() メソッド削除(L143-152, 36行削除) - ✅ 簡潔な削除理由コメント追加(L118-127) - ✅ 古いドキュメント更新(L23) ### if_lowering.rs - ✅ 直接 IfPhiContext 構造体生成に置き換え(L258-261) - ✅ Phase 61-6.1 実装コメント追加(L256) ## 削減効果 - **純削減**: -26 行(予想 -11 行を大幅に上回る) - **コード品質**: 薄いラッパー削除で間接層を減らし、直接的なコード記述に ## テスト結果 - ✅ JoinIR tests 全通過(56 passed) - ✅ ビルド成功(0 error, 0 warning) ## 設計原則 - **箱理論**: 不要な境界削除、直接アクセス可能に - **Fail-Fast**: エラーなし、期待通りの動作 - **ソースコード綺麗綺麗**: 明確なコメント、一貫性のある修正 Phase 61-5 削減計画の Wave 1 第1弾完了! 次: Phase 61-6.2 (dev フラグ削除)
This commit is contained in:
@ -253,13 +253,12 @@ impl<'a> LoopBuilder<'a> {
|
||||
if !joinir_success {
|
||||
// Phase 26-E: PhiBuilderBox SSOT統合(If PHI生成)
|
||||
// Legacy: merge_modified_with_control() → New: PhiBuilderBox::generate_phis()
|
||||
// Phase 61-6.1: set_if_context削除、直接IfPhiContextを生成
|
||||
let mut phi_builder = crate::mir::phi_core::phi_builder_box::PhiBuilderBox::new();
|
||||
|
||||
// Phase 26-F-3: ループ内if-mergeコンテキスト設定(ChatGPT設計)
|
||||
phi_builder.set_if_context(
|
||||
true, // in_loop_body = true
|
||||
carrier_names.clone(),
|
||||
);
|
||||
phi_builder.if_context = Some(crate::mir::phi_core::phi_builder_box::IfPhiContext {
|
||||
in_loop_body: true,
|
||||
loop_carrier_names: carrier_names.clone(),
|
||||
});
|
||||
|
||||
// Phase 35-5: if_body_local_merge.rs削除、ロジックはPhiBuilderBox内に統合
|
||||
let post_snapshots = if let Some(ref else_map) = else_var_map_end_opt {
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
//! # Phase 36 Responsibility Classification
|
||||
//!
|
||||
//! ## Loop-only methods (if-in-loop PHI)
|
||||
//! - `set_if_context()`: Set loop context for if-in-loop PHI generation
|
||||
//! - (Phase 61-6.1: set_if_context削除、if_context直接代入に)
|
||||
//!
|
||||
//! ## If-only methods (Phase 37 target)
|
||||
//! - `generate_if_phis()`: Generate If PHI nodes
|
||||
@ -72,7 +72,8 @@ use std::collections::BTreeMap;
|
||||
/// - **ピュア関数的**: 入力 → PHI生成 → 出力(副作用最小化)
|
||||
pub struct PhiBuilderBox {
|
||||
/// If PHI生成時のコンテキスト(将来拡張用)
|
||||
if_context: Option<IfPhiContext>,
|
||||
/// Phase 61-6.1: pub化(set_if_context削除、直接代入可能に)
|
||||
pub if_context: Option<IfPhiContext>,
|
||||
// Phase 30: loop_context 削除(完全未使用、将来 JoinIR で代替予定)
|
||||
}
|
||||
|
||||
@ -114,42 +115,16 @@ impl PhiBuilderBox {
|
||||
Self { if_context: None }
|
||||
}
|
||||
|
||||
/// Phase 26-F-3: ループ内if-mergeコンテキストを設定
|
||||
///
|
||||
/// # Responsibility: Loop-only (if-in-loop PHI)
|
||||
///
|
||||
/// This method is ONLY called from loop_builder.rs for if-in-loop PHI generation.
|
||||
/// It sets the loop context (carrier variable names) for proper PHI generation
|
||||
/// in "片腕のみの変数" cases (e.g., `if i >= n { break }`).
|
||||
///
|
||||
/// ## Phase 36 Scope
|
||||
/// - Called via loop_builder.rs directly (no wrapper needed)
|
||||
/// - Minimal indirection for performance
|
||||
///
|
||||
/// ## Phase 37+ Consideration
|
||||
/// - May be internalized when loop-in-loop PHI is refactored
|
||||
/// - Consider merging with IfPhiContext initialization
|
||||
///
|
||||
/// # Arguments
|
||||
/// - `in_loop_body`: ループbody内のif-mergeか
|
||||
/// - `loop_carrier_names`: ループキャリア変数名(Pinned + Carrier)
|
||||
///
|
||||
/// # Usage (LoopBuilder側で呼ぶ)
|
||||
/// ```ignore
|
||||
/// let mut phi_builder = PhiBuilderBox::new();
|
||||
/// phi_builder.set_if_context(true, carrier_names_set);
|
||||
/// phi_builder.generate_phis(...);
|
||||
/// ```
|
||||
pub fn set_if_context(
|
||||
&mut self,
|
||||
in_loop_body: bool,
|
||||
loop_carrier_names: std::collections::BTreeSet<String>,
|
||||
) {
|
||||
self.if_context = Some(IfPhiContext {
|
||||
in_loop_body,
|
||||
loop_carrier_names,
|
||||
});
|
||||
}
|
||||
// Phase 61-6.1: set_if_context() 削除(薄いラッパー)
|
||||
// 呼び出し側(loop_builder/if_lowering.rs)で直接 IfPhiContext を生成
|
||||
//
|
||||
// Before:
|
||||
// phi_builder.set_if_context(true, carrier_names.clone());
|
||||
// After:
|
||||
// phi_builder.if_context = Some(IfPhiContext {
|
||||
// in_loop_body: true,
|
||||
// loop_carrier_names: carrier_names.clone(),
|
||||
// });
|
||||
|
||||
// Phase 26-F-2: set_body_local_filter() 削除
|
||||
// Phase 35-5: if_body_local_merge.rs削除、ロジックをcompute_modified_names_if()内に直接実装
|
||||
|
||||
Reference in New Issue
Block a user