Initial investigation: Identified core Box registration issues

Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-12 08:12:26 +00:00
parent a2c8f84de5
commit dadb5afcff
7 changed files with 94 additions and 16 deletions

View File

@ -107,7 +107,8 @@ pub mod regex;
// P2P通信Box群 (NEW! - Completely rewritten)
pub mod intent_box;
pub mod p2p_box;
// Temporarily commented out until transport/messaging import issues are fixed
// pub mod p2p_box;
// null関数も再エクスポート
pub use null_box::{NullBox, null};
@ -125,4 +126,5 @@ pub use regex::RegexBox;
// P2P通信Boxの再エクスポート
pub use intent_box::IntentBox;
pub use p2p_box::P2PBox;
// Temporarily commented out until transport/messaging import issues are fixed
// pub use p2p_box::P2PBox;

View File

@ -8,7 +8,7 @@
use super::*;
use crate::ast::UnaryOperator;
use crate::boxes::{buffer::BufferBox, JSONBox, HttpClientBox, StreamBox, RegexBox, IntentBox, P2PBox};
use crate::boxes::{buffer::BufferBox, JSONBox, HttpClientBox, StreamBox, RegexBox, IntentBox};
use crate::boxes::{FloatBox, MathBox, ConsoleBox, TimeBox, DateTimeBox, RandomBox, SoundBox, DebugBox, file::FileBox, MapBox};
use crate::box_trait::BoolBox;
use crate::operator_traits::OperatorResolver;
@ -453,10 +453,10 @@ impl NyashInterpreter {
return self.execute_intent_box_method(intent_box, method, arguments);
}
// P2PBox method calls
if let Some(p2p_box) = obj_value.as_any().downcast_ref::<P2PBox>() {
return self.execute_p2p_box_method(p2p_box, method, arguments);
}
// P2PBox method calls - Temporarily disabled
// if let Some(p2p_box) = obj_value.as_any().downcast_ref::<P2PBox>() {
// return self.execute_p2p_box_method(p2p_box, method, arguments);
// }
// EguiBox method calls (非WASM環境のみ)
#[cfg(not(target_arch = "wasm32"))]

View File

@ -7,7 +7,7 @@ use crate::interpreter::core::NyashInterpreter;
use crate::interpreter::core::RuntimeError;
use crate::ast::ASTNode;
use crate::box_trait::{NyashBox, StringBox, BoolBox};
use crate::boxes::{IntentBox, P2PBox};
use crate::boxes::{IntentBox};
use crate::method_box::MethodBox;
impl NyashInterpreter {
@ -45,7 +45,8 @@ impl NyashInterpreter {
}
}
/// P2PBoxのメソッド実行 (Arc<Mutex>版)
// P2PBoxのメソッド実行 (Arc<Mutex>版) - Temporarily disabled
/*
pub(in crate::interpreter) fn execute_p2p_box_method(
&mut self,
p2p_box: &P2PBox,
@ -114,4 +115,5 @@ impl NyashInterpreter {
})
}
}
*/
}

View File

@ -502,13 +502,10 @@ impl NyashInterpreter {
});
};
let transport_kind = transport_str.parse::<crate::boxes::p2p_box::TransportKind>()
.map_err(|e| RuntimeError::InvalidOperation {
message: format!("Invalid transport type '{}': {}", transport_str, e),
})?;
let p2p_box = crate::boxes::p2p_box::P2PBoxData::new(node_id, transport_kind);
return Ok(Box::new(p2p_box) as Box<dyn NyashBox>);
// TODO: Re-enable P2PBox after fixing transport/messaging imports
return Err(RuntimeError::TypeError {
message: "P2PBox temporarily disabled due to import issues".to_string(),
});
}
"StreamBox" => {
// StreamBoxは引数なしで作成

View File

@ -0,0 +1,32 @@
// Test Basic Box Constructor Issues (Problem 1)
// This should demonstrate the core failures described in the issue
local console = new ConsoleBox()
console.log("=== Testing Basic Box Constructors ===")
// Test StringBox constructor
console.log("Testing StringBox constructor...")
local str_box = new StringBox("test")
console.log("StringBox created: " + str_box.toString())
// Test IntegerBox constructor
console.log("Testing IntegerBox constructor...")
local int_box = new IntegerBox(123)
console.log("IntegerBox created: " + int_box.toString())
// Test BoolBox constructor
console.log("Testing BoolBox constructor...")
local bool_box = new BoolBox(false)
console.log("BoolBox created: " + bool_box.toString())
// Compare with literals (these should work)
console.log("=== Comparing with Literals ===")
local str_literal = "test"
local int_literal = 123
local bool_literal = false
console.log("String literal: " + str_literal)
console.log("Integer literal: " + int_literal)
console.log("Bool literal: " + bool_literal)
console.log("Test complete!")

View File

@ -0,0 +1,22 @@
// Test FloatBox Issues (Problem 4)
// This should demonstrate the FloatBox value access issues
local console = new ConsoleBox()
console.log("=== Testing FloatBox Issues ===")
// Test FloatBox creation (this should work)
console.log("Creating FloatBox...")
local float = new FloatBox(3.14)
console.log("FloatBox created successfully")
// Test toString method (this should work)
console.log("Testing toString...")
local float_str = float.toString()
console.log("FloatBox toString: " + float_str)
// Test value field access (this should fail)
console.log("Testing value field access...")
// local value = float.value
// console.log("FloatBox value: " + value)
console.log("FloatBox test complete!")

View File

@ -0,0 +1,23 @@
// Test IntentBox Field Access Issues (Problem 2)
// This should demonstrate the field access failures described
local console = new ConsoleBox()
console.log("=== Testing IntentBox Field Access ===")
// Test IntentBox creation (this should work)
console.log("Creating IntentBox...")
local intent = new IntentBox("test", "Hello")
console.log("IntentBox created successfully")
// Test field access methods (these should be the issue)
console.log("Testing field access...")
// Try getName method
local name = intent.getName()
console.log("Intent name: " + name)
// Try getPayload method
local payload = intent.getPayload()
console.log("Intent payload: " + payload)
console.log("Field access test complete!")