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

@ -87,6 +87,21 @@ This document specifies the official 26-instruction set for Nyash MIR (Machine I
%dst = call %box.method(%arg1, %arg2, ...)
```
Effect: context-dependent
**重要な識別方法:**
- BoxCall形式: `call %値.メソッド名(引数)` - 値(%7などに対してメソッドを直接呼ぶ
- 通常のCall形式: `call %関数値(%me, 引数)` - 関数値を呼び、第1引数にmeを渡す
例:
```mir
; BoxCallプラグイン/ビルトインBoxのメソッド
%17 = call %7.open(%14, %16)
%22 = call %7.write(%21)
; 通常のCallユーザー定義Boxのメソッド
%func = const "UserBox.method/2"
%result = call %func(%me, %arg1)
```
13. **ExternCall** - Call external function
```mir