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:
@ -126,6 +126,42 @@ impl NyashInterpreter {
|
||||
}
|
||||
Ok(string_box.to_lower())
|
||||
}
|
||||
"toInteger" => {
|
||||
if !arguments.is_empty() {
|
||||
return Err(RuntimeError::InvalidOperation {
|
||||
message: format!("toInteger() expects 0 arguments, got {}", arguments.len()),
|
||||
});
|
||||
}
|
||||
Ok(string_box.to_integer())
|
||||
}
|
||||
"substring" => {
|
||||
if arguments.len() != 2 {
|
||||
return Err(RuntimeError::InvalidOperation {
|
||||
message: format!("substring() expects 2 arguments, got {}", arguments.len()),
|
||||
});
|
||||
}
|
||||
let start = self.execute_expression(&arguments[0])?;
|
||||
let end = self.execute_expression(&arguments[1])?;
|
||||
|
||||
// Convert arguments to integers
|
||||
let start_int = if let Some(int_box) = start.as_any().downcast_ref::<IntegerBox>() {
|
||||
int_box.value as usize
|
||||
} else {
|
||||
return Err(RuntimeError::TypeError {
|
||||
message: "substring() expects integer arguments".to_string(),
|
||||
});
|
||||
};
|
||||
|
||||
let end_int = if let Some(int_box) = end.as_any().downcast_ref::<IntegerBox>() {
|
||||
int_box.value as usize
|
||||
} else {
|
||||
return Err(RuntimeError::TypeError {
|
||||
message: "substring() expects integer arguments".to_string(),
|
||||
});
|
||||
};
|
||||
|
||||
Ok(string_box.substring(start_int, end_int))
|
||||
}
|
||||
_ => {
|
||||
Err(RuntimeError::InvalidOperation {
|
||||
message: format!("Unknown method '{}' for StringBox", method),
|
||||
|
||||
Reference in New Issue
Block a user