Files
hakorune/src/mir/builder/calls/call_target.rs
Selfhosting Dev 2f306dd6a5 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>
2025-09-25 09:01:55 +09:00

58 lines
1.5 KiB
Rust

/*!
* Call Target Types
*
* Type-safe call target specification for unified call system
* Part of Phase 15.5 MIR Call unification
*/
use crate::mir::ValueId;
/// Call target specification for emit_unified_call
/// Provides type-safe target resolution at the builder level
#[derive(Debug, Clone)]
pub enum CallTarget {
/// Global function (print, panic, etc.)
Global(String),
/// Method call (box.method)
Method {
box_type: Option<String>, // None = infer from value
method: String,
receiver: ValueId,
},
/// Constructor (new BoxType)
Constructor(String),
/// External function (nyash.*)
Extern(String),
/// Dynamic function value
Value(ValueId),
/// Closure creation
Closure {
params: Vec<String>,
captures: Vec<(String, ValueId)>,
me_capture: Option<ValueId>,
},
}
impl CallTarget {
/// Check if this target is a constructor
pub fn is_constructor(&self) -> bool {
matches!(self, CallTarget::Constructor(_))
}
/// Get the name of the target for debugging
pub fn name(&self) -> String {
match self {
CallTarget::Global(name) => name.clone(),
CallTarget::Method { method, .. } => method.clone(),
CallTarget::Constructor(box_type) => format!("new {}", box_type),
CallTarget::Extern(name) => name.clone(),
CallTarget::Value(_) => "<dynamic>".to_string(),
CallTarget::Closure { .. } => "<closure>".to_string(),
}
}
}