feat: 大規模リファクタリング - SRP原則に基づくモジュール分割

## MIR builder_calls.rs リファクタリング
- 879行 → 629行 (28%削減) + 7専門モジュール
- calls/ ディレクトリに機能別分割:
  - call_target.rs: CallTarget型定義
  - method_resolution.rs: メソッド解決ロジック
  - extern_calls.rs: 外部呼び出し処理
  - special_handlers.rs: 特殊ハンドラー
  - function_lowering.rs: 関数変換ユーティリティ
  - call_unified.rs: 統一Call実装
  - mod.rs: モジュール統合

## Parser statements.rs リファクタリング
- 723行 → 8専門モジュール
- statements/ ディレクトリに機能別分割:
  - control_flow.rs: if/loop/break/continue/return
  - declarations.rs: 宣言系ディスパッチャー
  - exceptions.rs: try/throw/catch/cleanup
  - helpers.rs: ヘルパー関数
  - io_async.rs: print/nowait
  - modules.rs: import/using/from
  - variables.rs: local/outbox/assignments
  - mod.rs: 統合モジュール

## 効果
 単一責任原則(SRP)の達成
 保守性・再利用性の向上
 ChatGPT5 Pro設計の型安全Call解決システム実装
 スモークテスト通過確認済み

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-25 09:01:55 +09:00
parent 26d181cac3
commit 2f306dd6a5
23 changed files with 1819 additions and 1616 deletions

View File

@ -20,13 +20,14 @@
mod common;
mod cursor; // TokenCursor: 改行処理を一元管理
mod declarations;
mod depth_tracking; // Phase 1: 深度追跡機能(Smart advance用)
// depth_tracking.rs was a legacy depth counter for Smart advance.
// Phase 15.5: removed in favor of TokenCursor-centric newline handling.
pub mod entry_sugar; // helper to parse with sugar level
mod expr;
mod expr_cursor; // TokenCursorを使用した式パーサー実験的
mod expressions;
mod items;
mod statements;
mod statements; // Now uses modular structure in statements/
pub mod sugar; // Phase 12.7-B: desugar pass (basic)
pub mod sugar_gate; // thread-local gate for sugar parsing (tests/docs)
// mod errors;
@ -139,13 +140,9 @@ pub struct NyashParser {
std::collections::HashMap<String, std::collections::HashSet<String>>,
/// 🔥 デバッグ燃料:無限ループ検出用制限値 (None = 無制限)
pub(super) debug_fuel: Option<usize>,
/// Phase 1: Smart advance用深度カウンタ改行自動スキップ判定
pub(super) paren_depth: usize, // ()
pub(super) brace_depth: usize, // {}
pub(super) bracket_depth: usize, // []
}
// ParserUtils trait implementation is in depth_tracking.rs
// ParserUtils trait implementation now lives here (legacy depth tracking removed)
impl NyashParser {
/// 新しいパーサーを作成
@ -155,9 +152,6 @@ impl NyashParser {
current: 0,
static_box_dependencies: std::collections::HashMap::new(),
debug_fuel: Some(100_000), // デフォルト値
paren_depth: 0,
brace_depth: 0,
bracket_depth: 0,
}
}
@ -349,3 +343,12 @@ impl NyashParser {
// ===== 🔥 Static Box循環依存検出 =====
}
// ---- Minimal ParserUtils impl (depth-less; TokenCursor handles newline policy) ----
impl common::ParserUtils for NyashParser {
fn tokens(&self) -> &Vec<Token> { &self.tokens }
fn current(&self) -> usize { self.current }
fn current_mut(&mut self) -> &mut usize { &mut self.current }
fn update_depth_before_advance(&mut self) { /* no-op (legacy removed) */ }
fn update_depth_after_advance(&mut self) { /* no-op (legacy removed) */ }
}