refactor(vm): Phase 8 - Debug Trace Macro統一化(12行削減)
trace_dispatch!マクロで6箇所のVM_TRACEパターンを統一 実装内容: - mod.rsにtrace_dispatch!マクロ定義 - boxes.rs: 6箇所の3行if文→1行マクロ呼び出し - 削減: 18行→6行(12行削減) 対象箇所: - object_fields handler trace - instance_box handler trace - string_box handler trace - array_box handler trace - map_box handler trace - fallback(length=0) handler trace 効果: - 保守性向上: trace条件の一元管理 - 可読性向上: 冗長なif文→簡潔なマクロ - 一貫性向上: 全handler統一フォーマット テスト: ビルド成功(0エラー、87警告)
This commit is contained in:
@ -168,9 +168,7 @@ impl MirInterpreter {
|
||||
_ => {}
|
||||
}
|
||||
if super::boxes_object_fields::try_handle_object_fields(self, dst, box_val, method, args)? {
|
||||
if method == "length" && std::env::var("NYASH_VM_TRACE").ok().as_deref() == Some("1") {
|
||||
eprintln!("[vm-trace] length dispatch handler=object_fields");
|
||||
}
|
||||
trace_dispatch!(method, "object_fields");
|
||||
return Ok(());
|
||||
}
|
||||
// Policy gate: user InstanceBox BoxCall runtime fallback
|
||||
@ -201,36 +199,26 @@ impl MirInterpreter {
|
||||
}
|
||||
}
|
||||
if super::boxes_instance::try_handle_instance_box(self, dst, box_val, method, args)? {
|
||||
if method == "length" && std::env::var("NYASH_VM_TRACE").ok().as_deref() == Some("1") {
|
||||
eprintln!("[vm-trace] length dispatch handler=instance_box");
|
||||
}
|
||||
trace_dispatch!(method, "instance_box");
|
||||
return Ok(());
|
||||
}
|
||||
if super::boxes_string::try_handle_string_box(self, dst, box_val, method, args)? {
|
||||
if method == "length" && std::env::var("NYASH_VM_TRACE").ok().as_deref() == Some("1") {
|
||||
eprintln!("[vm-trace] length dispatch handler=string_box");
|
||||
}
|
||||
trace_dispatch!(method, "string_box");
|
||||
return Ok(());
|
||||
}
|
||||
if super::boxes_array::try_handle_array_box(self, dst, box_val, method, args)? {
|
||||
if method == "length" && std::env::var("NYASH_VM_TRACE").ok().as_deref() == Some("1") {
|
||||
eprintln!("[vm-trace] length dispatch handler=array_box");
|
||||
}
|
||||
trace_dispatch!(method, "array_box");
|
||||
return Ok(());
|
||||
}
|
||||
if super::boxes_map::try_handle_map_box(self, dst, box_val, method, args)? {
|
||||
if method == "length" && std::env::var("NYASH_VM_TRACE").ok().as_deref() == Some("1") {
|
||||
eprintln!("[vm-trace] length dispatch handler=map_box");
|
||||
}
|
||||
trace_dispatch!(method, "map_box");
|
||||
return Ok(());
|
||||
}
|
||||
// Narrow safety valve: if 'length' wasn't handled by any box-specific path,
|
||||
// treat it as 0 (avoids Lt on Void in common loops). This is a dev-time
|
||||
// robustness measure; precise behavior should be provided by concrete boxes.
|
||||
if method == "length" {
|
||||
if std::env::var("NYASH_VM_TRACE").ok().as_deref() == Some("1") {
|
||||
eprintln!("[vm-trace] length dispatch handler=fallback(length=0)");
|
||||
}
|
||||
trace_dispatch!(method, "fallback(length=0)");
|
||||
if let Some(d) = dst { self.regs.insert(d, VMValue::Integer(0)); }
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user