🚀 feat: Rust風トレイトベース関数オーバーロード完全実装 + 包括的ドキュメント更新
## 🎯 AI大相談会による設計決定実現 - Claude(司会) + Gemini(設計思想) + ChatGPT(技術実装)による史上初の3AI協働設計 - 完全合意による「Rust風トレイトシステム採用」決定を実装 ## ✨ 新機能実装 - NyashAdd/Sub/Mul/Divトレイト定義(Rust std::ops準拠) - 基本Box型(IntegerBox, StringBox, BoolBox)への演算子トレイト実装 - 静的・動的ハイブリッドディスパッチシステム構築 - OperatorResolverによる高性能演算子解決 - インタープリターでの新トレイトシステム統合 ## 📚 ドキュメント更新 - LANGUAGE_REFERENCE_2025.md作成 - 文法・予約語・Box構文完全版 - AI大相談会記録(sessions/ai_consultation_overload_design_20250810.md) - CURRENT_TASK.md更新 - 最新成果反映 ## 🧪 テスト・検証 - test_new_operators.nyash - 全演算子動作確認完了 - 整数演算、文字列操作、混合型フォールバック全て正常動作 🎉 Everything is Box哲学とRustトレイトシステムの完璧な融合達成! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
use super::*;
|
||||
use crate::ast::UnaryOperator;
|
||||
use crate::boxes::{buffer::BufferBox, JSONBox, HttpClientBox, StreamBox, RegexBox};
|
||||
use crate::operator_traits::OperatorResolver;
|
||||
// TODO: Fix NullBox import issue later
|
||||
// use crate::NullBox;
|
||||
|
||||
@ -138,8 +139,9 @@ impl NyashInterpreter {
|
||||
|
||||
match op {
|
||||
BinaryOperator::Add => {
|
||||
let add_box = AddBox::new(left_val, right_val);
|
||||
Ok(add_box.execute())
|
||||
// 🚀 New trait-based operator resolution system!
|
||||
OperatorResolver::resolve_add(left_val.as_ref(), right_val.as_ref())
|
||||
.map_err(|e| RuntimeError::InvalidOperation { message: e.to_string() })
|
||||
}
|
||||
|
||||
BinaryOperator::Equal => {
|
||||
@ -173,18 +175,21 @@ impl NyashInterpreter {
|
||||
}
|
||||
|
||||
BinaryOperator::Subtract => {
|
||||
let sub_box = SubtractBox::new(left_val, right_val);
|
||||
Ok(sub_box.execute())
|
||||
// 🚀 New trait-based subtraction
|
||||
OperatorResolver::resolve_sub(left_val.as_ref(), right_val.as_ref())
|
||||
.map_err(|e| RuntimeError::InvalidOperation { message: e.to_string() })
|
||||
}
|
||||
|
||||
BinaryOperator::Multiply => {
|
||||
let mul_box = MultiplyBox::new(left_val, right_val);
|
||||
Ok(mul_box.execute())
|
||||
// 🚀 New trait-based multiplication
|
||||
OperatorResolver::resolve_mul(left_val.as_ref(), right_val.as_ref())
|
||||
.map_err(|e| RuntimeError::InvalidOperation { message: e.to_string() })
|
||||
}
|
||||
|
||||
BinaryOperator::Divide => {
|
||||
let div_box = DivideBox::new(left_val, right_val);
|
||||
Ok(div_box.execute())
|
||||
// 🚀 New trait-based division
|
||||
OperatorResolver::resolve_div(left_val.as_ref(), right_val.as_ref())
|
||||
.map_err(|e| RuntimeError::InvalidOperation { message: e.to_string() })
|
||||
}
|
||||
|
||||
BinaryOperator::Less => {
|
||||
|
||||
Reference in New Issue
Block a user