refactor(mir): Phase 137-6-S1 - choose_pattern_kind SSOT入口を新設

## 目的
Pattern 選択ロジックを SSOT 化し、将来の Canonicalizer 委譲に備える

## 変更内容

### 新規関数: `choose_pattern_kind()`
- 場所: `src/mir/builder/control_flow/joinir/routing.rs`
- 責務: Pattern 選択の SSOT 入口
- 実装: 既存の LoopFeatures ベース選択ロジックを集約

### LoopPatternContext の更新
- `new()` で `choose_pattern_kind()` を使用
- 既存の分散した選択ロジックを SSOT に統一

## 効果
-  Pattern 選択ロジックの SSOT 化(1箇所に集約)
-  将来の Canonicalizer 委譲に備えた構造確立
-  既定挙動完全不変(既存テスト全て PASS)

## テスト結果
-  `cargo build --release`: 成功
-  スモークテスト(simple_*): 5/5 PASS
-  退行なし

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-16 07:37:23 +09:00
parent 3026251323
commit fc4c343d88
4 changed files with 61 additions and 15 deletions

View File

@ -70,6 +70,7 @@ impl<'a> LoopPatternContext<'a> {
/// Phase 192: Extract features and classify pattern from AST
/// Phase 193: Feature extraction delegated to ast_feature_extractor module
/// Phase 131-11: Detects infinite loop condition
/// Phase 137-6-S1: Use choose_pattern_kind() SSOT entry point
pub(crate) fn new(
condition: &'a ASTNode,
body: &'a [ASTNode],
@ -84,8 +85,9 @@ impl<'a> LoopPatternContext<'a> {
// Phase 131-11: Pass condition for infinite loop detection
let features = ast_features::extract_features(condition, body, has_continue, has_break);
// Phase 192: Classify pattern based on features
let pattern_kind = crate::mir::loop_pattern_detection::classify(&features);
// Phase 137-6-S1: Use SSOT pattern selection entry point
use crate::mir::builder::control_flow::joinir::routing::choose_pattern_kind;
let pattern_kind = choose_pattern_kind(condition, body);
Self {
condition,