Files
hakorune/docs/CURRENT_TASK.md
Moe Charm e5e381aa83 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>
2025-08-20 00:21:20 +09:00

142 lines
4.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🎯 現在のタスク (2025-08-19 更新)
## 🚧 進行中: Phase 9.78e instance_v2移行最終段階
### 🎉 **Phase 9.78e: 重要マイルストーン達成済み**
- ✅ instance.rs完全削除成功
- ✅ 統一レジストリによるユーザー定義Box生成成功
- ✅ コンストラクタ実行成功
- ✅ インポート問題完全解決
### 🔥 **現在の課題: InstanceBoxラップ演算子問題**
#### 💥 **具体的なエラー**
```bash
❌ Runtime error:
⚠️ Invalid operation: Addition not supported between StringBox and StringBox
```
#### 🔍 **根本原因**
1. **BuiltinBoxFactory**がStringBoxを`InstanceBox::from_any_box()`でラップして返す
2. **演算子処理**try_add_operationが直接StringBoxを期待
3. **実際の構造**: `InstanceBox<StringBox>` vs 期待: `StringBox`
#### 🎯 **解決方針: シンプル実装アプローチ**
**ChatGPT5/Gemini先生への相談結果**: 段階的実装を推奨
**選択した戦略**:
```rust
// unwrap_instanceヘルパー関数30分で実装可能
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
}
```
**修正対象**: 4つの演算子関数のみ
- try_add_operation
- try_sub_operation
- try_mul_operation
- try_div_operation
#### 🏆 **完了事項**
- ✅ インポート問題解決(バイナリビルド)
- ✅ 完全パス使用箇所をuse文で修正
- ✅ ユーザー定義Boxの統一レジストリ登録問題
- ✅ コンストラクタ実行成功
- ✅ Person("Alice", 25) → init実行確認
#### ⚡ **次の実装ステップ30分で完了予定**
1. **unwrap_instanceヘルパー関数実装** ← 進行中
- 場所: `src/interpreter/expressions/operators.rs`
- 役割: InstanceBoxでラップされた場合、内部のBoxを取得
2. **4つの演算子関数を修正**
- try_add_operation: 文字列結合とIntegerBox加算
- try_sub_operation: IntegerBox減算
- try_mul_operation: IntegerBox乗算、StringBox繰り返し
- try_div_operation: IntegerBox除算、ゼロ除算エラー処理
3. **テスト実行**
- `./target/debug/nyash local_tests/test_instance_v2_migration.nyash`
- 期待結果: Person created, Hello I'm Alice, フィールドアクセス成功
#### 🎯 **成功の指標**
```nyash
local alice = new Person("Alice", 25)
alice.greet() // ← これが成功すれば完了!
print("Name: " + alice.name) // ← StringBox演算子が動けば完了
```
## 🚀 次のステップ: レガシー互換層のクリーンアップ
### 🎯 **instance_v2の純粋化**
**現状**: instance_v2にレガシー互換層が残存段階的削除予定
1. **クリーンアップ対象**:
- レガシーfields → fields_ngに完全統一
- get_field_legacy/set_field_legacy等の互換メソッド削除
- SharedNyashBox ↔ NyashValue型変換の適切な実装
2. **バイナリビルド修正**:
- importパスエラー修正crate::instance_v2
- テスト実行環境の整備
3. **性能最適化**:
- 不要なMutex削除検討
- 型変換オーバーヘッド削減
---
## ✅ 完了: Phase 9.78a-d BoxFactory革命
### 🎉 Phase 9.78d 達成結果
**InstanceBox簡素化統一実装成功**
#### 🏭 実装完了内容
1. **✅ Phase 9.78a: BoxFactory基盤実装**
- 統合レジストリアーキテクチャ完成
- 600+行match文 → 30行に削減
2. **✅ Phase 9.78b: ビルトインBox統合**
- 20+種類のBox型統合完了
- **ビルド時間: 4分 → 43秒 (5.6倍高速化!)**
3. **✅ Phase 9.78c: プラグインBox統合**
- BID-FFI Step 1-3実装成功
- plugin-testerツール完成
4. **✅ Phase 9.78d: InstanceBox簡素化**
- StringBox → InstanceBox統合完成
- type_name()委譲実装
- 基本機能完全動作
### 📊 新しいビルドコマンド
```bash
# 高速ビルド(通常開発用): ~43秒
cargo build --release -j32
# WASM機能付きビルド必要時のみ: ~4分
cargo build --release -j32 --features wasm-backend
```
---
## 🎯 今後の優先事項copilot_issues.txt参照
### Phase 8.4: AST→MIR Lowering完全実装
- MIR命令セット設計済み35命令
- Lowering実装開始準備
### Phase 8.5: MIRダイエット35→20命令
- 命令セット最適化による性能改善
### Phase 8.6: VM性能改善0.9倍→2倍以上
- レジスタ割り当て最適化
- インライン展開
最終更新: 2025-08-19 - Phase 9.78e完全勝利instance.rs削除成功、instance_v2が唯一の実装に