chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
Phase 25.1 完了成果: - ✅ LoopForm v2 テスト・ドキュメント・コメント完備 - 4ケース(A/B/C/D)完全テストカバレッジ - 最小再現ケース作成(SSAバグ調査用) - SSOT文書作成(loopform_ssot.md) - 全ソースに [LoopForm] コメントタグ追加 - ✅ Stage-1 CLI デバッグ環境構築 - stage1_cli.hako 実装 - stage1_bridge.rs ブリッジ実装 - デバッグツール作成(stage1_debug.sh/stage1_minimal.sh) - アーキテクチャ改善提案文書 - ✅ 環境変数削減計画策定 - 25変数の完全調査・分類 - 6段階削減ロードマップ(25→5、80%削減) - 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG) Phase 26-D からの累積変更: - PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等) - MIRビルダーリファクタリング - 型伝播・最適化パス改善 - その他約300ファイルの累積変更 🎯 技術的成果: - SSAバグ根本原因特定(条件分岐内loop変数変更) - Region+next_iパターン適用完了(UsingCollectorBox等) - LoopFormパターン文書化・テスト化完了 - セルフホスティング基盤強化 Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: ChatGPT <noreply@openai.com> Co-Authored-By: Task Assistant <task@anthropic.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* Control Flow Utilities - 制御フロー処理の共通ユーティリティ
|
||||
*
|
||||
*
|
||||
* PHI incoming修正とブロック終端検出の汎用関数群
|
||||
* フェーズS(即効止血)からフェーズL(根本解決)まで共通利用
|
||||
*/
|
||||
@ -8,9 +8,9 @@
|
||||
use super::super::{BasicBlockId, MirBuilder};
|
||||
|
||||
/// **外部関数**: 現在のブロックが終端済みかチェック
|
||||
///
|
||||
///
|
||||
/// loop_builder.rsで3箇所重複していた処理を統一
|
||||
///
|
||||
///
|
||||
/// # 使用例
|
||||
/// ```rust
|
||||
/// if is_current_block_terminated(builder)? {
|
||||
@ -18,9 +18,10 @@ use super::super::{BasicBlockId, MirBuilder};
|
||||
/// }
|
||||
/// ```
|
||||
pub fn is_current_block_terminated(builder: &MirBuilder) -> Result<bool, String> {
|
||||
let cur_id = builder.current_block
|
||||
let cur_id = builder
|
||||
.current_block
|
||||
.ok_or_else(|| "No current block".to_string())?;
|
||||
|
||||
|
||||
if let Some(ref function) = builder.current_function {
|
||||
if let Some(bb) = function.get_block(cur_id) {
|
||||
Ok(bb.is_terminated())
|
||||
@ -33,14 +34,14 @@ pub fn is_current_block_terminated(builder: &MirBuilder) -> Result<bool, String>
|
||||
}
|
||||
|
||||
/// **外部関数**: 実到達ブロックを捕捉してJump発行
|
||||
///
|
||||
///
|
||||
/// 最強モード指摘の「実到達predecessor捕捉」を汎用化
|
||||
/// break/continue後の到達不能ブロックは除外
|
||||
///
|
||||
///
|
||||
/// # 戻り値
|
||||
/// - `Some(predecessor_id)`: Jump発行済み、PHI incomingに使用可能
|
||||
/// - `None`: 既に終端済み、PHI incomingから除外すべき
|
||||
///
|
||||
///
|
||||
/// # 使用例
|
||||
/// ```rust
|
||||
/// if let Some(pred_id) = capture_actual_predecessor_and_jump(builder, merge_bb)? {
|
||||
@ -51,16 +52,17 @@ pub fn capture_actual_predecessor_and_jump(
|
||||
builder: &mut MirBuilder,
|
||||
target_block: BasicBlockId,
|
||||
) -> Result<Option<BasicBlockId>, String> {
|
||||
let cur_id = builder.current_block
|
||||
let cur_id = builder
|
||||
.current_block
|
||||
.ok_or_else(|| "No current block".to_string())?;
|
||||
|
||||
|
||||
let need_jump = !is_current_block_terminated(builder)?;
|
||||
|
||||
|
||||
if need_jump {
|
||||
// Jump発行前に実到達ブロックID捕捉(重要!)
|
||||
// 既存control_flowモジュールと同じパターンを使用
|
||||
builder.emit_instruction(super::super::MirInstruction::Jump {
|
||||
target: target_block
|
||||
builder.emit_instruction(super::super::MirInstruction::Jump {
|
||||
target: target_block,
|
||||
})?;
|
||||
Ok(Some(cur_id))
|
||||
} else {
|
||||
@ -70,10 +72,10 @@ pub fn capture_actual_predecessor_and_jump(
|
||||
}
|
||||
|
||||
/// **外部関数**: 条件付きPHI incoming収集
|
||||
///
|
||||
///
|
||||
/// 到達可能な場合のみincomingをリストに追加
|
||||
/// フェーズM、フェーズLでの型安全性向上にも対応
|
||||
///
|
||||
///
|
||||
/// # 使用例
|
||||
/// ```rust
|
||||
/// let mut incomings = Vec::new();
|
||||
@ -92,10 +94,10 @@ pub fn collect_phi_incoming_if_reachable(
|
||||
}
|
||||
|
||||
/// **外部関数**: 終端チェック付きステートメント実行
|
||||
///
|
||||
///
|
||||
/// build_statement後の終端チェックを自動化
|
||||
/// フェーズSでの「終端ガード徹底」を支援
|
||||
///
|
||||
///
|
||||
/// # 戻り値
|
||||
/// - `Ok(true)`: 正常実行、継続可能
|
||||
/// - `Ok(false)`: 終端済み、ループ脱出すべき
|
||||
@ -105,7 +107,7 @@ pub fn execute_statement_with_termination_check(
|
||||
statement: crate::ast::ASTNode,
|
||||
) -> Result<bool, String> {
|
||||
let _result = builder.build_expression(statement)?;
|
||||
|
||||
|
||||
// 終端チェック(統一処理)
|
||||
let terminated = is_current_block_terminated(builder)?;
|
||||
Ok(!terminated)
|
||||
@ -114,9 +116,9 @@ pub fn execute_statement_with_termination_check(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
||||
// ユニットテスト(将来追加)
|
||||
// - 終端検出の正確性
|
||||
// - 実到達ブロック捕捉の正確性
|
||||
// - PHI incoming除外の正確性
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user