fix: Kilo/CHIP-8アプリエラー修正 - toInteger, substring, レガシーBox削除

## 修正内容
1. **toIntegerメソッド実装** (#125)
   - StringBoxにtoInteger()メソッド追加
   - box_trait::IntegerBoxを返すよう統一(レガシーboxes::IntegerBox削除)

2. **substringメソッド実装**
   - StringBoxにsubstring(start, end)メソッド追加
   - Kiloエディタで必要な文字列操作を完全サポート

3. **レガシーコード削除**
   - src/boxes/mod.rsから重複StringBox/IntegerBox/BoolBoxエクスポート削除
   - 全てbox_trait実装に統一

4. **プラグインドキュメント整理**
   - 古い仕様書に「理想案・未実装」「将来構想」明記
   - 実装ベースの正確な仕様書作成
   - migration-guide.md追加

## テスト結果
-  Kiloエディタ: 完全動作確認("Enhanced Kilo Editor test complete")
-  toInteger()の乗算: 正常動作
-  substring(): 正常動作

🤖 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 14:13:47 +09:00
parent 163cab0c25
commit 3e8b75f4de
15 changed files with 1020 additions and 15 deletions

View File

@ -221,10 +221,15 @@ impl NyashInterpreter {
// オブジェクトを評価(通常のメソッド呼び出し)
let obj_value = self.execute_expression(object)?;
eprintln!("🔍 DEBUG: execute_method_call - object type: {}, method: {}", obj_value.type_name(), method);
// StringBox method calls
eprintln!("🔍 DEBUG: Checking StringBox downcast for type: {}", obj_value.type_name());
if let Some(string_box) = obj_value.as_any().downcast_ref::<StringBox>() {
eprintln!("🔍 DEBUG: StringBox detected, calling execute_string_method");
return self.execute_string_method(string_box, method, arguments);
} else {
eprintln!("🔍 DEBUG: StringBox downcast failed");
}
// IntegerBox method calls
@ -495,7 +500,7 @@ impl NyashInterpreter {
return self.execute_plugin_box_v2_method(plugin_box, method, arguments);
}
// InstanceBox method calls
// ⚠️ InstanceBox method calls (最後にチェック、ビルトインBoxの後)
if let Some(instance) = obj_value.as_any().downcast_ref::<InstanceBox>() {
// 🔥 Usage prohibition guard - check if instance is finalized
if instance.is_finalized() {
@ -690,6 +695,7 @@ impl NyashInterpreter {
})
}
} else {
eprintln!("🔍 DEBUG: Reached non-instance type error for type: {}, method: {}", obj_value.type_name(), method);
Err(RuntimeError::TypeError {
message: format!("Cannot call method '{}' on non-instance type", method),
})