feat: Implement Phase 9.78e instance_v2 migration with unified registry

Major achievements:
-  UserDefinedBoxFactory implementation with unified registry integration
-  Constructor execution for user-defined boxes (Person init working)
-  Import path fixes across interpreter modules
-  unwrap_instance helper function for InstanceBox operator support

Technical details:
- Modified UnifiedBoxRegistry to handle empty box_types() factories
- Implemented constructor execution in execute_new for InstanceBox
- Added unwrap_instance helper to handle InstanceBox wrapping in operators
- Updated CURRENT_TASK.md with detailed progress tracking

Next: Fix 4 operator functions to complete InstanceBox operator support

🤖 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:21:20 +09:00
parent 5a50cf6415
commit e5e381aa83
9 changed files with 274 additions and 70 deletions

View File

@ -8,8 +8,20 @@ use crate::box_trait::{NyashBox, IntegerBox, BoolBox, CompareBox};
use crate::boxes::StringBox; // 🔧 統一レジストリと一致させる
use crate::boxes::FloatBox;
use crate::interpreter::core::{NyashInterpreter, RuntimeError};
use crate::instance_v2::InstanceBox;
// Local helper functions to bypass import issues
/// InstanceBoxでラップされている場合、内部のBoxを取得する
/// シンプルなヘルパー関数で型地獄を回避
fn unwrap_instance(boxed: &dyn NyashBox) -> &dyn NyashBox {
if let Some(instance) = boxed.as_any().downcast_ref::<InstanceBox>() {
if let Some(ref inner) = instance.inner_content {
return inner.as_ref();
}
}
boxed
}
pub(super) fn try_add_operation(left: &dyn NyashBox, right: &dyn NyashBox) -> Option<Box<dyn NyashBox>> {
// 🔍 デバッグ出力追加
eprintln!("🔍 try_add_operation: left={}, right={}", left.type_name(), right.type_name());