refactor(joinir): Phase 82 SSOT統一化 - テーブル化とヘルパー抽象化
Phase 82: JoinIR関数リストとExecルートの SSOT 統一化 ## 変更内容 ### 1. JOINIR_TARGETS テーブル統一化 **targets.rs**: vm_bridge_dispatch テーブルが唯一のSSO - FuncScannerBox.append_defs/2 を Exec に追加 - is_loop_lowered_function() はここから参照 - コメントに Phase 82 SSOT マーク **mod.rs**: is_loop_lowered_function() 簡素化 - JOINIR_TARGETS テーブルから参照に統一 - Exec/LowerOnly 両方を Loop lowered対象とする - ハードコード関数リストを削除 ✅ ### 2. Exec routes 統一ヘルパー **exec_routes.rs**: run_generic_joinir_route() 追加 - try_run_skip_ws() / try_run_trim() の共通パターンを抽象化 - 入出力値フォーマッタ、終了コードエキスプレッサをコールバック化 - 後方互換性のため既存関数は保持 - 将来フェーズで統合可能 (#[allow(dead_code)]) ## テスト結果 ✅ test_is_loop_lowered_function PASS ✅ cargo build --release SUCCESS ## 重複排除の効果 - テーブル重複: ハードコード関数リスト完全排除 - ロジック重複: 統一ヘルパーで28行削減可能(将来) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -59,6 +59,9 @@ use crate::mir::{BasicBlockId, MirFunction};
|
||||
/// これらの関数は Phase 32/33 で LoopToJoinLowerer によって処理されます。
|
||||
/// If lowering (Select/IfMerge) の対象から除外することで、Loop/If の責務を明確に分離します。
|
||||
///
|
||||
/// Phase 82 SSOT: JOINIR_TARGETS テーブルから Exec 対象を参照
|
||||
/// (テーブルは vm_bridge_dispatch/targets.rs で一元管理)
|
||||
///
|
||||
/// ## 対象関数(6本)
|
||||
/// - Main.skip/1: 空白スキップループ
|
||||
/// - FuncScannerBox.trim/1: 前後空白削除ループ
|
||||
@ -70,16 +73,12 @@ use crate::mir::{BasicBlockId, MirFunction};
|
||||
/// ## 将来の拡張
|
||||
/// NYASH_JOINIR_LOWER_GENERIC=1 で汎用 Case-A ループにも拡張可能
|
||||
pub(crate) fn is_loop_lowered_function(name: &str) -> bool {
|
||||
const LOOP_LOWERED_FUNCTIONS: &[&str] = &[
|
||||
"Main.skip/1",
|
||||
"FuncScannerBox.trim/1",
|
||||
"FuncScannerBox.append_defs/2",
|
||||
"Stage1UsingResolverBox.resolve_for_source/5",
|
||||
"StageBBodyExtractorBox.build_body_src/2",
|
||||
"StageBFuncScannerBox.scan_all_boxes/1",
|
||||
];
|
||||
|
||||
LOOP_LOWERED_FUNCTIONS.contains(&name)
|
||||
// Phase 82 SSOT: vm_bridge_dispatch テーブルから Loop 関数を抽出
|
||||
// Phase 33-9.1: If lowering の除外対象は、JOINIR_TARGETS に登録されたすべての関数
|
||||
// (Exec/LowerOnly 問わず、ループ専任関数として Loop lowering で処理)
|
||||
crate::mir::join_ir_vm_bridge_dispatch::JOINIR_TARGETS
|
||||
.iter()
|
||||
.any(|t| t.func_name == name)
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user