✨ 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>
43 lines
1.4 KiB
Rust
43 lines
1.4 KiB
Rust
use super::ValueId;
|
|
use crate::ast::ASTNode;
|
|
|
|
impl super::MirBuilder {
|
|
// Indirect call: (callee)(args...)
|
|
pub(super) fn build_indirect_call_expression(
|
|
&mut self,
|
|
callee: ASTNode,
|
|
arguments: Vec<ASTNode>,
|
|
) -> Result<ValueId, String> {
|
|
let callee_id = self.build_expression_impl(callee)?;
|
|
let mut arg_ids: Vec<ValueId> = Vec::new();
|
|
for a in arguments {
|
|
arg_ids.push(self.build_expression_impl(a)?);
|
|
}
|
|
|
|
// Phase 3.1: Use unified call with CallTarget::Value for indirect calls
|
|
let use_unified = std::env::var("NYASH_MIR_UNIFIED_CALL").unwrap_or_default() == "1";
|
|
|
|
if use_unified {
|
|
// New unified path - use emit_unified_call with Value target
|
|
let dst = self.value_gen.next();
|
|
self.emit_unified_call(
|
|
Some(dst),
|
|
super::builder_calls::CallTarget::Value(callee_id),
|
|
arg_ids,
|
|
)?;
|
|
Ok(dst)
|
|
} else {
|
|
// Legacy path - keep for compatibility
|
|
let dst = self.value_gen.next();
|
|
self.emit_instruction(super::MirInstruction::Call {
|
|
dst: Some(dst),
|
|
func: callee_id,
|
|
callee: None, // Legacy call expression - use old resolution
|
|
args: arg_ids,
|
|
effects: super::EffectMask::PURE,
|
|
})?;
|
|
Ok(dst)
|
|
}
|
|
}
|
|
}
|