docs: Add field visibility analysis and MIR BoxCall documentation

## Field Visibility Analysis Results
- Confirmed init{} fields are **public** in current Nyash implementation
- No access modifier (private/public) system currently implemented
- All fields accessible via me.fieldname syntax
- Documented findings for future reference

## MIR Documentation Enhancements
- Created comprehensive mir-dumper-guide.md for reading MIR dumps
- Enhanced mir-26-specification.md with BoxCall vs regular Call examples
- Added clear identification patterns:
  * BoxCall: `call %value.method(args)` (plugins/builtins)
  * Regular Call: `call %func(%me, args)` (user-defined boxes)

## VM Backend BoxRef Handling Improvements
- Fixed BoxRef method dispatch using share_box() instead of clone_box()
- Prevents unintended constructor calls during method resolution
- Maintains proper instance identity throughout VM execution

## MIR Builder User-Defined Box Tracking
- Added user_defined_boxes HashSet to track declared user boxes
- Improved method lowering decisions for user-defined vs builtin boxes
- Enhanced AST→MIR conversion accuracy for method calls

## Plugin Tester Lifecycle Enhancements
- Added comprehensive FileBox lifecycle testing (open/write/close)
- Enhanced cloneSelf() and copyFrom() testing with proper Handle parsing
- Added TLV encoding helpers for strings and bytes
- Improved error reporting and step-by-step validation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-21 01:18:25 +09:00
parent cc2a820af7
commit 2200312f09
5 changed files with 183 additions and 49 deletions

View File

@ -90,8 +90,8 @@ impl VMValue {
VMValue::String(s) => Box::new(StringBox::new(s)),
VMValue::Future(f) => Box::new(f.clone()),
VMValue::Void => Box::new(VoidBox::new()),
// Phase 9.78a: BoxRef returns cloned Box
VMValue::BoxRef(arc_box) => arc_box.clone_box(),
// BoxRef returns a shared handle (do NOT birth a new instance)
VMValue::BoxRef(arc_box) => arc_box.share_box(),
}
}
@ -504,7 +504,8 @@ impl VM {
// Handle BoxRef for proper method dispatch
let box_nyash = match &box_vm_value {
VMValue::BoxRef(arc_box) => arc_box.clone_box(),
// Use shared handle to avoid unintended constructor calls
VMValue::BoxRef(arc_box) => arc_box.share_box(),
_ => box_vm_value.to_nyash_box(),
};
@ -607,8 +608,8 @@ impl VM {
};
match created {
Ok(b) => {
// Register for scope-based finalization (clone for registration)
let reg_arc = std::sync::Arc::from(b.clone_box());
// Register for scope-based finalization (share; keep same instance)
let reg_arc = std::sync::Arc::from(b.share_box());
self.scope_tracker.register_box(reg_arc);
// Store value in VM
self.set_value(*dst, VMValue::from_nyash_box(b));