Phase 2 Complete: Conditional debug system + Final verification
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com>
This commit is contained in:
@ -10,6 +10,15 @@ use crate::instance_v2::InstanceBox;
|
||||
use crate::interpreter::core::{NyashInterpreter, RuntimeError};
|
||||
use std::sync::Arc;
|
||||
|
||||
// Conditional debug macro - only outputs if NYASH_DEBUG=1 environment variable is set
|
||||
macro_rules! debug_trace {
|
||||
($($arg:tt)*) => {
|
||||
if std::env::var("NYASH_DEBUG").unwrap_or_default() == "1" {
|
||||
eprintln!($($arg)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl NyashInterpreter {
|
||||
/// フィールドアクセスを実行 - Field access processing with weak reference support
|
||||
pub(super) fn execute_field_access(&mut self, object: &ASTNode, field: &str)
|
||||
@ -54,12 +63,12 @@ impl NyashInterpreter {
|
||||
if let Some(weak_value) = instance.get_weak_field(field, self) { // Pass self
|
||||
match &weak_value {
|
||||
crate::value::NyashValue::Null => {
|
||||
eprintln!("🔗 DEBUG: Weak field '{}' is null (reference dropped)", field);
|
||||
debug_trace!("🔗 DEBUG: Weak field '{}' is null (reference dropped)", field);
|
||||
// Return null box for compatibility
|
||||
return Ok(Arc::new(crate::boxes::null_box::NullBox::new()));
|
||||
}
|
||||
_ => {
|
||||
eprintln!("🔗 DEBUG: Weak field '{}' still has valid reference", field);
|
||||
debug_trace!("🔗 DEBUG: Weak field '{}' still has valid reference", field);
|
||||
// Convert back to Box<dyn NyashBox> for now
|
||||
if let Ok(box_value) = weak_value.to_box() {
|
||||
if let Ok(inner_box) = box_value.try_lock() {
|
||||
|
||||
Reference in New Issue
Block a user