feat(joinir): Phase 48-2 from_loop_form method for Trio absorption

- Add LoopScopeShape::from_loop_form() that creates Trio internally
- Remove LoopExitLivenessBox import from loop_to_join.rs
- Switch loop_to_join.rs to use from_loop_form() instead of from_existing_boxes()

This is the first step in absorbing Classifier Trio into LoopScopeShape.
External Trio dependency reduced from 3 boxes to 2 (intake_loop_form only).

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-28 19:00:03 +09:00
parent 66097f7553
commit 1714eaa00c
2 changed files with 42 additions and 17 deletions

View File

@ -253,6 +253,41 @@ impl LoopScopeShape {
Self::from_existing_boxes_legacy(loop_form, intake, var_classes, exit_live_box, query)
}
/// Phase 48-2: Trio引数なしでLoopScopeShapeを構築
///
/// # Purpose
///
/// 外部からTrioを渡す必要をなくし、LoopScopeShape内部に完全吸収。
/// `loop_to_join.rs` などで空のTrioを作成して渡すパターンを解消する。
///
/// # Arguments
///
/// - `loop_form`: LoopForm containing block structure
/// - `intake`: LoopFormIntake containing classified variable info
/// - `query`: MirQuery for liveness computation
/// - `func_name`: Optional function name for Case-A minimal routing
///
/// # Returns
///
/// Some(LoopScopeShape) if successful, None if critical data is missing.
///
/// # History
///
/// - Phase 48-2: 新規追加Trio依存の内部化
pub(crate) fn from_loop_form(
loop_form: &LoopForm,
intake: &LoopFormIntake,
query: &impl MirQuery,
func_name: Option<&str>,
) -> Option<Self> {
// Phase 48-2: Trio を内部で作成(空箱)
let var_classes = LoopVarClassBox::new();
let exit_live_box = LoopExitLivenessBox::new();
// 既存の from_existing_boxes を呼び出し
Self::from_existing_boxes(loop_form, intake, &var_classes, &exit_live_box, query, func_name)
}
/// Check if a variable needs header PHI
#[allow(dead_code)] // Phase 30: will be used in F-3 generic lowering
pub fn needs_header_phi(&self, var_name: &str) -> bool {

View File

@ -31,8 +31,7 @@ use crate::mir::join_ir::lowering::loop_form_intake::intake_loop_form;
use crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape;
use crate::mir::join_ir::JoinModule;
use crate::mir::loop_form::LoopForm;
use crate::mir::phi_core::loop_exit_liveness::LoopExitLivenessBox;
use crate::mir::phi_core::loop_var_classifier::LoopVarClassBox;
// Phase 48-2: Trio imports removed - now internal to LoopScopeShape::from_loop_form()
use crate::mir::query::MirQueryBox;
use crate::mir::MirFunction;
@ -98,22 +97,13 @@ impl LoopToJoinLowerer {
// Step 1: MirQuery を構築
let query = MirQueryBox::new(func);
// Step 2: 分類箱を構築Phase 31 では空箱、将来 MIR 解析で埋める)
let var_classes = LoopVarClassBox::new();
let exit_live = LoopExitLivenessBox::new();
// Step 2: LoopFormIntake を構築
// Phase 48-2: intake_loop_form は空の var_classes を使用(将来は from_loop_form に統合)
let intake = intake_loop_form(loop_form, &Default::default(), &query, func)?;
// Step 3: LoopFormIntake を構築
let intake = intake_loop_form(loop_form, &var_classes, &query, func)?;
// Step 4: LoopScopeShape を構築
let scope = LoopScopeShape::from_existing_boxes(
loop_form,
&intake,
&var_classes,
&exit_live,
&query,
func_name,
)?;
// Step 3: LoopScopeShape を構築
// Phase 48-2: from_loop_form() で Trio を内部化LoopExitLivenessBox 依存削除)
let scope = LoopScopeShape::from_loop_form(loop_form, &intake, &query, func_name)?;
if self.debug {
eprintln!(