feat: MIR Call命令統一Phase 3.1-3.2完了!統一Call実装進行中

 Phase 3.1-3.2実装完了
- build_indirect_call_expressionでCallTarget::Value使用
- print関数をcall_global print()として統一
- build_function_callでemit_unified_call使用
- ExternCall(env.console.log)→Callee::Global(print)完全移行

🏗️ MIR統一基盤構築
- src/mir/definitions/call_unified.rs: 統一定義(297行)
- emit_unified_call()と便利メソッド3種実装
- NYASH_MIR_UNIFIED_CALL=1で段階移行制御
- VM実行器でCallee対応実装済み

📊 進捗状況(26%削減見込み)
- Phase 1-2:  基盤構築完了
- Phase 3.1-3.2:  基本関数統一完了
- Phase 3.3: 🔄 BoxCall統一中
- Phase 4: 📅 Python LLVM(最優先・63%削減)
- Phase 5: 📅 PyVM/VM統一

📚 ドキュメント更新
- CLAUDE.md: テストスクリプト参考集追加
- CURRENT_TASK.md: Phase 3進捗更新
- python-llvm-priority-rationale.md: 優先順位戦略文書化
- mir-call-unification-master-plan.md: スケジュール最新化

🎯 6種類→1種類: Call/BoxCall/PluginInvoke/ExternCall/NewBox/NewClosure → MirCall統一へ

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-24 01:05:44 +09:00
parent 96fd74916c
commit 81211c22ad
29 changed files with 2850 additions and 113 deletions

View File

@ -63,6 +63,7 @@ pub fn format_instruction(
MirInstruction::Call {
dst,
func,
callee,
args,
effects: _,
} => {
@ -72,18 +73,51 @@ pub fn format_instruction(
.collect::<Vec<_>>()
.join(", ");
if let Some(dst) = dst {
format!(
"{} call {}({})",
format_dst(dst, types),
func,
args_str
)
// ✅ MIRダンプCallee表示改良 - ChatGPT5 Pro革命
let call_display = if let Some(callee_info) = callee {
match callee_info {
super::Callee::Global(name) => {
format!("call_global {}({})", name, args_str)
}
super::Callee::Method { box_name, method, receiver } => {
if let Some(recv) = receiver {
format!("call_method {}.{}({}) [recv: {}]", box_name, method, args_str, recv)
} else {
format!("call_method {}.{}({})", box_name, method, args_str)
}
}
super::Callee::Constructor { box_type } => {
format!("call_constructor {}({})", box_type, args_str)
}
super::Callee::Closure { params, captures, me_capture } => {
let params_str = params.join(", ");
let captures_str = captures.iter()
.map(|(name, val)| format!("{}={}", name, val))
.collect::<Vec<_>>()
.join(", ");
let me_str = me_capture.map_or(String::new(), |v| format!(" [me={}]", v));
format!("call_closure ({}) [captures: {}]{}",
params_str, captures_str, me_str)
}
super::Callee::Value(func_val) => {
format!("call_value {}({})", func_val, args_str)
}
super::Callee::Extern(extern_name) => {
format!("call_extern {}({})", extern_name, args_str)
}
}
} else {
format!("call {}({})", func, args_str)
// LEGACY: 従来の表示(後方互換性)
format!("call_legacy {}({})", func, args_str)
};
if let Some(dst) = dst {
format!("{} {}", format_dst(dst, types), call_display)
} else {
call_display
}
}
MirInstruction::FunctionNew {
MirInstruction::NewClosure {
dst,
params,
body,
@ -99,7 +133,7 @@ pub fn format_instruction(
let me_s = me.map(|m| format!(" me={}", m)).unwrap_or_default();
let cap_s = if c.is_empty() { String::new() } else { format!(" [{}]", c) };
format!(
"{} function_new ({}) {{...{}}}{}{}",
"{} new_closure ({}) {{...{}}}{}{}",
format_dst(dst, types),
p,
body.len(),