diff --git a/docs/CURRENT_TASK.md b/docs/CURRENT_TASK.md index 2f8e10ad..d898f6ef 100644 --- a/docs/CURRENT_TASK.md +++ b/docs/CURRENT_TASK.md @@ -1,20 +1,21 @@ -# 🎯 現在のタスク (2025-08-15 Phase 9.75完了・Phase 9.5開始準備) +# 🎯 現在のタスク (2025-08-15 Phase 9.75D進行中・PR #97 フェーズC完了) -## ❌ **Phase 9.75未完了: Arc → RwLock変換に重大問題** -- **コンパイル**: エラー0個 ✅ -- **実行時**: 状態保持が機能しない 🚨 -- **問題**: RwLock変換自体は正しいが、インタープリター側で状態同期されない +## ✅ **PR #97 フェーズC完了確認済み** +- **核心実装**: clone_box() vs share_box() 責務分離完全実装 ✅ +- **変数アクセス修正**: `expressions.rs:108` で `share_box()` 使用 ✅ +- **主要Box修正**: ArrayBox, MapBox, BufferBox, SocketBox で Arc + share_box() 実装済み ✅ +- **状態保持テスト**: 新規追加、ArrayBox状態保持問題の根本解決確認 ✅ -## 🚨 **緊急問題(Phase 9.75未完了)** -**ArrayBox状態保持問題**: `push()`後に`length()`が0を返す深刻なバグ -- **根本原因**: インタープリターで`clone_box()`により毎回新しいインスタンス作成 -- **影響**: 全Box型で状態変更が保持されない可能性(Arc→RwLock変換の副作用) -- **場所**: `src/interpreter/expressions.rs:334` の `(*shared_var).clone_box()` -- **対応**: Phase 9.75を再調査・修正が必要(「完了」表記は誤り) +## 🚨 **現在の課題: 74個の構文エラー修正中** +**問題**: 仮実装された20個のBox型で `share_box()` メソッドの構文エラー +- **原因**: `clone_box()` 内に `share_box()` が誤挿入される構文問題 +- **進捗**: NullBox, ConsoleBox, TimerBox修正完了 (3/20) +- **残り**: 17個のBox型で同様の構文修正が必要 -## 🔧 **最優先タスク: Phase 9.75 完全修正** -**目標**: ArrayBox状態保持問題の根本解決 -**重点**: インタープリターの参照管理修正(Phase 9.5は延期) +## 🎯 **フェーズD準備完了状況** +**成功部分**: ArrayBox状態保持問題の根本解決完了 +**Gemini設計**: clone_box(値) vs share_box(参照) 責務分離アーキテクチャ実装済み +**次段階**: 構文エラー修正完了後、VM/WASMバックエンド対応(フェーズD) ## 📈 **完了済みPhase要約** - **Phase 8**: MIR/WASM基盤構築、13.5倍高速化実証 ✅ diff --git a/src/box_arithmetic.rs b/src/box_arithmetic.rs index 1b46d333..5a1d5d32 100644 --- a/src/box_arithmetic.rs +++ b/src/box_arithmetic.rs @@ -112,6 +112,11 @@ impl NyashBox for AddBox { self.right.clone_box() )) } + + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for AddBox { @@ -217,6 +222,11 @@ impl NyashBox for SubtractBox { fn clone_box(&self) -> Box { Box::new(SubtractBox::new(self.left.clone_box(), self.right.clone_box())) } + + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for SubtractBox { @@ -309,6 +319,11 @@ impl NyashBox for MultiplyBox { fn clone_box(&self) -> Box { Box::new(MultiplyBox::new(self.left.clone_box(), self.right.clone_box())) } + + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for MultiplyBox { @@ -410,6 +425,11 @@ impl NyashBox for DivideBox { fn clone_box(&self) -> Box { Box::new(DivideBox::new(self.left.clone_box(), self.right.clone_box())) } + + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for DivideBox { diff --git a/src/box_trait.rs b/src/box_trait.rs index 84f56136..4eada1c0 100644 --- a/src/box_trait.rs +++ b/src/box_trait.rs @@ -248,6 +248,10 @@ impl NyashBox for StringBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl Display for StringBox { @@ -319,6 +323,10 @@ impl NyashBox for IntegerBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl Display for IntegerBox { @@ -394,6 +402,10 @@ impl NyashBox for BoolBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl Display for BoolBox { @@ -461,6 +473,10 @@ impl NyashBox for VoidBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl Display for VoidBox { @@ -571,6 +587,10 @@ impl NyashBox for FileBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl Display for FileBox { @@ -640,6 +660,10 @@ impl NyashBox for ErrorBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl Display for ErrorBox { @@ -785,6 +809,10 @@ impl NyashBox for ResultBox { } } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl Display for ResultBox { diff --git a/src/boxes/audio_box.rs b/src/boxes/audio_box.rs index 7d8a5bc1..bcea374a 100644 --- a/src/boxes/audio_box.rs +++ b/src/boxes/audio_box.rs @@ -304,15 +304,14 @@ impl BoxCore for AudioBox { impl NyashBox for AudioBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("AudioBox(volume={:.2}, playing={})", self.volume, self.is_playing)) } diff --git a/src/boxes/canvas_event_box.rs b/src/boxes/canvas_event_box.rs index 4095d2f6..3ca7258c 100644 --- a/src/boxes/canvas_event_box.rs +++ b/src/boxes/canvas_event_box.rs @@ -272,15 +272,14 @@ impl BoxCore for CanvasEventBox { impl NyashBox for CanvasEventBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("CanvasEventBox({})", self.canvas_id)) } diff --git a/src/boxes/canvas_loop_box.rs b/src/boxes/canvas_loop_box.rs index 3ff1dd2f..6e288814 100644 --- a/src/boxes/canvas_loop_box.rs +++ b/src/boxes/canvas_loop_box.rs @@ -282,15 +282,14 @@ impl BoxCore for CanvasLoopBox { impl NyashBox for CanvasLoopBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("CanvasLoopBox(running={}, fps={:.1})", self.is_running, self.fps)) } diff --git a/src/boxes/console_box.rs b/src/boxes/console_box.rs index f9131bc1..d2e0e3c1 100644 --- a/src/boxes/console_box.rs +++ b/src/boxes/console_box.rs @@ -121,14 +121,13 @@ impl NyashBox for ConsoleBox { } fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - - Box::new(self.clone()) - } } @@ -201,14 +200,13 @@ impl NyashBox for ConsoleBox { } fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - - Box::new(self.clone()) - } } diff --git a/src/boxes/egui_box.rs b/src/boxes/egui_box.rs index 0e42d910..902c9c34 100644 --- a/src/boxes/egui_box.rs +++ b/src/boxes/egui_box.rs @@ -154,14 +154,13 @@ impl NyashBox for EguiBox { } fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - - Box::new(self.clone()) - } fn equals(&self, other: &dyn NyashBox) -> BoolBox { diff --git a/src/boxes/extern_box.rs b/src/boxes/extern_box.rs index ed84b4b1..d98a7a6d 100644 --- a/src/boxes/extern_box.rs +++ b/src/boxes/extern_box.rs @@ -2,7 +2,7 @@ * ExternBox - External API proxy for Phase 9.7 ExternCall */ -use crate::box_trait::{NyashBox, StringBox, VoidBox, IntegerBox, BoxCore, BoxBase}; +use crate::box_trait::{NyashBox, StringBox, BoolBox, VoidBox, IntegerBox, BoxCore, BoxBase}; use std::any::Any; /// External API proxy box for external calls @@ -28,6 +28,18 @@ impl ExternBox { } impl BoxCore for ExternBox { + fn box_id(&self) -> u64 { + self.id + } + + fn parent_type_id(&self) -> Option { + None // ExternBox doesn't inherit from other built-in boxes + } + + fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "ExternBox({})", self.api_name) + } + fn as_any(&self) -> &dyn Any { self } @@ -35,30 +47,35 @@ impl BoxCore for ExternBox { fn as_any_mut(&mut self) -> &mut dyn Any { self } +} - fn box_clone(&self) -> Box { +impl NyashBox for ExternBox { + fn to_string_box(&self) -> StringBox { + StringBox::new(format!("ExternBox({})", self.api_name)) + } + + fn equals(&self, other: &dyn NyashBox) -> BoolBox { + if let Some(other_extern) = other.as_any().downcast_ref::() { + BoolBox::new(self.id == other_extern.id) + } else { + BoolBox::new(false) + } + } + + fn type_name(&self) -> &'static str { + "ExternBox" + } + + fn clone_box(&self) -> Box { Box::new(ExternBox { id: self.id, api_name: self.api_name.clone(), }) } - - fn box_eq(&self, other: &dyn NyashBox) -> bool { - if let Some(other_extern) = other.as_any().downcast_ref::() { - self.id == other_extern.id - } else { - false - } - } -} - -impl NyashBox for ExternBox { - fn get_type_name(&self) -> &str { - "ExternBox" - } - - fn to_string(&self) -> String { - format!("ExternBox({})", self.api_name) + + fn share_box(&self) -> Box { + // ExternBox is stateless, so share_box and clone_box behave the same + self.clone_box() } fn call_method(&mut self, method: &str, args: Vec>) -> Box { @@ -69,42 +86,42 @@ impl NyashBox for ExternBox { print!("Console: "); for (i, arg) in args.iter().enumerate() { if i > 0 { print!(" "); } - print!("{}", arg.to_string()); + print!("{}", arg.to_string_box().value); } println!(); - VoidBox::new() + Box::new(VoidBox::new()) }, ("canvas", "fillRect") => { if args.len() >= 6 { println!("Canvas fillRect: canvas={}, x={}, y={}, w={}, h={}, color={}", - args[0].to_string(), - args[1].to_string(), - args[2].to_string(), - args[3].to_string(), - args[4].to_string(), - args[5].to_string()); + args[0].to_string_box().value, + args[1].to_string_box().value, + args[2].to_string_box().value, + args[3].to_string_box().value, + args[4].to_string_box().value, + args[5].to_string_box().value); } else { println!("Canvas fillRect called with {} args (expected 6)", args.len()); } - VoidBox::new() + Box::new(VoidBox::new()) }, ("canvas", "fillText") => { if args.len() >= 6 { println!("Canvas fillText: canvas={}, text={}, x={}, y={}, font={}, color={}", - args[0].to_string(), - args[1].to_string(), - args[2].to_string(), - args[3].to_string(), - args[4].to_string(), - args[5].to_string()); + args[0].to_string_box().value, + args[1].to_string_box().value, + args[2].to_string_box().value, + args[3].to_string_box().value, + args[4].to_string_box().value, + args[5].to_string_box().value); } else { println!("Canvas fillText called with {} args (expected 6)", args.len()); } - VoidBox::new() + Box::new(VoidBox::new()) }, _ => { println!("Unknown external method: {}.{}", self.api_name, method); - VoidBox::new() + Box::new(VoidBox::new()) } } } diff --git a/src/boxes/file/mod.rs b/src/boxes/file/mod.rs index 111640f3..982bee0a 100644 --- a/src/boxes/file/mod.rs +++ b/src/boxes/file/mod.rs @@ -134,18 +134,17 @@ impl BoxCore for FileBox { impl NyashBox for FileBox { fn clone_box(&self) -> Box { - - /// 仮実装: clone_boxと同じ(後で修正) - fn share_box(&self) -> Box { - self.clone_box() - } - // Note: Cannot truly clone a File handle, so create a new one to the same path match FileBox::open(&self.path) { Ok(new_file) => Box::new(new_file), Err(_) => Box::new(crate::box_trait::VoidBox::new()) // Return void on error } } + + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } fn to_string_box(&self) -> StringBox { StringBox::new(format!("FileBox({})", self.path)) diff --git a/src/boxes/future/mod.rs b/src/boxes/future/mod.rs index bd916f98..a22b07b9 100644 --- a/src/boxes/future/mod.rs +++ b/src/boxes/future/mod.rs @@ -73,15 +73,14 @@ impl NyashFutureBox { impl NyashBox for NyashFutureBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { let ready = *self.is_ready.read().unwrap(); if ready { diff --git a/src/boxes/http/mod.rs b/src/boxes/http/mod.rs index 0f9966d1..dc570ad3 100644 --- a/src/boxes/http/mod.rs +++ b/src/boxes/http/mod.rs @@ -49,15 +49,14 @@ impl HttpClientBox { impl NyashBox for HttpClientBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("HttpClientBox(id: {})", self.base.id)) } diff --git a/src/boxes/http_message_box.rs b/src/boxes/http_message_box.rs index 6b43dbc5..9e5003fe 100644 --- a/src/boxes/http_message_box.rs +++ b/src/boxes/http_message_box.rs @@ -193,15 +193,14 @@ impl HTTPRequestBox { impl NyashBox for HTTPRequestBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("HTTPRequest({} {} - {} headers)", self.method, self.path, self.headers.len())) @@ -377,15 +376,14 @@ impl HTTPResponseBox { impl NyashBox for HTTPResponseBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("HTTPResponse({} {} - {} bytes)", self.status_code, self.status_message, self.body.len())) diff --git a/src/boxes/http_server_box.rs b/src/boxes/http_server_box.rs index c282cbb1..26fe2834 100644 --- a/src/boxes/http_server_box.rs +++ b/src/boxes/http_server_box.rs @@ -365,15 +365,14 @@ impl HTTPServerBox { impl NyashBox for HTTPServerBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { let running = *self.running.read().unwrap(); let routes_count = self.routes.read().unwrap().len(); diff --git a/src/boxes/intent_box.rs b/src/boxes/intent_box.rs index 722dbb9d..02c71e3a 100644 --- a/src/boxes/intent_box.rs +++ b/src/boxes/intent_box.rs @@ -97,15 +97,14 @@ impl IntentBox { impl NyashBox for IntentBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { let name = self.name.read().unwrap().clone(); StringBox::new(format!("IntentBox[{}]", name)) diff --git a/src/boxes/json/mod.rs b/src/boxes/json/mod.rs index 4500ee46..1484f91f 100644 --- a/src/boxes/json/mod.rs +++ b/src/boxes/json/mod.rs @@ -173,15 +173,14 @@ impl std::fmt::Display for JSONBox { impl NyashBox for JSONBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { let value = self.value.read().unwrap(); StringBox::new(value.to_string()) diff --git a/src/boxes/null_box.rs b/src/boxes/null_box.rs index 9201ddef..b5dc4bfd 100644 --- a/src/boxes/null_box.rs +++ b/src/boxes/null_box.rs @@ -166,14 +166,13 @@ impl NyashBox for NullBox { } fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - - Box::new(self.clone()) - } fn equals(&self, other: &dyn NyashBox) -> BoolBox { // すべてのNullBoxは等しい diff --git a/src/boxes/p2p_box.rs b/src/boxes/p2p_box.rs index 694c95d1..159776b0 100644 --- a/src/boxes/p2p_box.rs +++ b/src/boxes/p2p_box.rs @@ -153,15 +153,14 @@ impl P2PBox { impl NyashBox for P2PBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { let node_id = self.node_id.read().unwrap().clone(); let transport_type = self.transport.read().unwrap().transport_type().to_string(); diff --git a/src/boxes/qr_box.rs b/src/boxes/qr_box.rs index 129aee8e..6e6a09c1 100644 --- a/src/boxes/qr_box.rs +++ b/src/boxes/qr_box.rs @@ -307,15 +307,14 @@ impl BoxCore for QRBox { impl NyashBox for QRBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("QRBox(type={}, size={}x{})", self.qr_type, self.size.0, self.size.1)) } diff --git a/src/boxes/regex/mod.rs b/src/boxes/regex/mod.rs index b9e5f066..009b17ab 100644 --- a/src/boxes/regex/mod.rs +++ b/src/boxes/regex/mod.rs @@ -83,15 +83,14 @@ impl RegexBox { impl NyashBox for RegexBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("RegexBox({})", self.pattern.as_str())) } diff --git a/src/boxes/result/mod.rs b/src/boxes/result/mod.rs index c9f12428..cfc8b9e4 100644 --- a/src/boxes/result/mod.rs +++ b/src/boxes/result/mod.rs @@ -38,17 +38,16 @@ impl NyashResultBox { impl NyashBox for NyashResultBox { fn clone_box(&self) -> Box { - - /// 仮実装: clone_boxと同じ(後で修正) - fn share_box(&self) -> Box { - self.clone_box() - } - match self { NyashResultBox::Ok(val) => Box::new(NyashResultBox::Ok(val.clone_box())), NyashResultBox::Err(err) => Box::new(NyashResultBox::Err(err.clone_box())), } } + + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } fn to_string_box(&self) -> StringBox { match self { diff --git a/src/boxes/simple_intent_box.rs b/src/boxes/simple_intent_box.rs index 68535677..19079538 100644 --- a/src/boxes/simple_intent_box.rs +++ b/src/boxes/simple_intent_box.rs @@ -231,14 +231,13 @@ impl NyashBox for SimpleIntentBox { } fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - - Box::new(self.clone()) - } } diff --git a/src/boxes/sound_box.rs b/src/boxes/sound_box.rs index bf728681..db6d874a 100644 --- a/src/boxes/sound_box.rs +++ b/src/boxes/sound_box.rs @@ -323,14 +323,13 @@ impl NyashBox for SoundBox { } fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - - Box::new(self.clone()) - } fn equals(&self, other: &dyn NyashBox) -> BoolBox { if let Some(other_sound) = other.as_any().downcast_ref::() { diff --git a/src/boxes/stream/mod.rs b/src/boxes/stream/mod.rs index 7a7b9788..a2598ca0 100644 --- a/src/boxes/stream/mod.rs +++ b/src/boxes/stream/mod.rs @@ -137,15 +137,14 @@ impl NyashStreamBox { impl NyashBox for NyashStreamBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { let buffer = self.buffer.read().unwrap(); let position = self.position.read().unwrap(); diff --git a/src/boxes/timer_box.rs b/src/boxes/timer_box.rs index 92df343b..4291d72a 100644 --- a/src/boxes/timer_box.rs +++ b/src/boxes/timer_box.rs @@ -215,15 +215,14 @@ impl BoxCore for TimerBox { impl NyashBox for TimerBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("TimerBox(id={})", self.base.id)) } diff --git a/src/boxes/web/web_canvas_box.rs b/src/boxes/web/web_canvas_box.rs index 47469777..dc68e30b 100644 --- a/src/boxes/web/web_canvas_box.rs +++ b/src/boxes/web/web_canvas_box.rs @@ -284,15 +284,14 @@ impl BoxCore for WebCanvasBox { #[cfg(target_arch = "wasm32")] impl NyashBox for WebCanvasBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!( "WebCanvasBox({}, {}x{})", diff --git a/src/boxes/web/web_console_box.rs b/src/boxes/web/web_console_box.rs index 6e0d9c27..30505631 100644 --- a/src/boxes/web/web_console_box.rs +++ b/src/boxes/web/web_console_box.rs @@ -161,15 +161,14 @@ impl BoxCore for WebConsoleBox { #[cfg(target_arch = "wasm32")] impl NyashBox for WebConsoleBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("WebConsoleBox({})", self.target_element_id)) } diff --git a/src/boxes/web/web_display_box.rs b/src/boxes/web/web_display_box.rs index 3b24b865..7631bd62 100644 --- a/src/boxes/web/web_display_box.rs +++ b/src/boxes/web/web_display_box.rs @@ -154,15 +154,14 @@ impl BoxCore for WebDisplayBox { #[cfg(target_arch = "wasm32")] impl NyashBox for WebDisplayBox { fn clone_box(&self) -> Box { + Box::new(self.clone()) + } /// 仮実装: clone_boxと同じ(後で修正) fn share_box(&self) -> Box { self.clone_box() } - Box::new(self.clone()) - } - fn to_string_box(&self) -> StringBox { StringBox::new(format!("WebDisplayBox({})", self.target_element_id)) } diff --git a/src/channel_box.rs b/src/channel_box.rs index 00c61aaa..d470a6a4 100644 --- a/src/channel_box.rs +++ b/src/channel_box.rs @@ -120,6 +120,11 @@ impl NyashBox for ChannelBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } + fn equals(&self, other: &dyn NyashBox) -> crate::box_trait::BoolBox { if let Some(other_channel) = other.as_any().downcast_ref::() { crate::box_trait::BoolBox::new( @@ -130,8 +135,6 @@ impl NyashBox for ChannelBox { crate::box_trait::BoolBox::new(false) } } - - } impl BoxCore for ChannelBox { @@ -203,6 +206,11 @@ impl NyashBox for MessageBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } + fn equals(&self, other: &dyn NyashBox) -> crate::box_trait::BoolBox { if let Some(other_msg) = other.as_any().downcast_ref::() { crate::box_trait::BoolBox::new( @@ -213,8 +221,6 @@ impl NyashBox for MessageBox { crate::box_trait::BoolBox::new(false) } } - - } impl BoxCore for MessageBox { diff --git a/src/exception_box.rs b/src/exception_box.rs index 79661707..bd2bd826 100644 --- a/src/exception_box.rs +++ b/src/exception_box.rs @@ -71,6 +71,10 @@ impl NyashBox for ErrorBox { Box::new(self.clone()) } + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for ErrorBox { diff --git a/src/instance.rs b/src/instance.rs index c6c10f34..72a13dbc 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -455,7 +455,10 @@ impl NyashBox for InstanceBox { Box::new(self.clone()) } - + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for InstanceBox { diff --git a/src/method_box.rs b/src/method_box.rs index 2dcd80a5..d92b1a84 100644 --- a/src/method_box.rs +++ b/src/method_box.rs @@ -119,7 +119,10 @@ impl NyashBox for MethodBox { Box::new(self.clone()) } - + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for MethodBox { diff --git a/src/type_box.rs b/src/type_box.rs index 9ce0b3fe..df9aafe1 100644 --- a/src/type_box.rs +++ b/src/type_box.rs @@ -254,7 +254,10 @@ impl NyashBox for TypeBox { Box::new(self.clone()) } - + /// 仮実装: clone_boxと同じ(後で修正) + fn share_box(&self) -> Box { + self.clone_box() + } } impl BoxCore for TypeBox {