feat: Phase 9.78e完全勝利!instance_v2移行100%成功

🎉 **InstanceBoxラップ演算子問題完全解決**
- unwrap_instanceヘルパー関数実装で型地獄回避
- 4つの演算子関数修正(add/sub/mul/div)
- StringBox + IntegerBox混在演算子完全動作

🚀 **Everything is Box哲学完全実現**
- 全Box型(ビルトイン、ユーザー定義、プラグイン)統一アーキテクチャ
- InstanceBoxによる完全統一ラッピング
- シンプルで保守可能な実装

 **全機能動作確認済み**
- Person/Employee作成・デリゲーション完全動作
- フィールドアクセス・メソッドオーバーライド成功
- 統一レジストリ完全統合

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-20 00:43:35 +09:00
parent e5e381aa83
commit 94e646ebc4
2 changed files with 58 additions and 49 deletions

View File

@ -26,6 +26,11 @@ pub(super) fn try_add_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Op
// 🔍 デバッグ出力追加
eprintln!("🔍 try_add_operation: left={}, right={}", left.type_name(), right.type_name());
// 🎯 InstanceBoxのunwrap処理
let left = unwrap_instance(left);
let right = unwrap_instance(right);
eprintln!("🔍 After unwrap: left={}, right={}", left.type_name(), right.type_name());
// IntegerBox + IntegerBox
if let (Some(left_int), Some(right_int)) = (
left.as_any().downcast_ref::<IntegerBox>(),
@ -57,6 +62,10 @@ pub(super) fn try_add_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Op
}
pub(super) fn try_sub_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Option<Box<dyn NyashBox>> {
// 🎯 InstanceBoxのunwrap処理
let left = unwrap_instance(left);
let right = unwrap_instance(right);
// IntegerBox - IntegerBox
if let (Some(left_int), Some(right_int)) = (
left.as_any().downcast_ref::<IntegerBox>(),
@ -68,6 +77,10 @@ pub(super) fn try_sub_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Op
}
pub(super) fn try_mul_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Option<Box<dyn NyashBox>> {
// 🎯 InstanceBoxのunwrap処理
let left = unwrap_instance(left);
let right = unwrap_instance(right);
// IntegerBox * IntegerBox
if let (Some(left_int), Some(right_int)) = (
left.as_any().downcast_ref::<IntegerBox>(),
@ -88,6 +101,10 @@ pub(super) fn try_mul_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Op
}
pub(super) fn try_div_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Result<Box<dyn NyashBox>, String> {
// 🎯 InstanceBoxのunwrap処理
let left = unwrap_instance(left);
let right = unwrap_instance(right);
// IntegerBox / IntegerBox
if let (Some(left_int), Some(right_int)) = (
left.as_any().downcast_ref::<IntegerBox>(),