Commit Graph

146 Commits

Author SHA1 Message Date
9c94e88b86 ResultBox migration (stage 0): suppress legacy deprecation warnings in box_trait impls; keep dual handling in VM. Fix verifier Display for SuspiciousBarrierContext. Expose VM stats fields to vm_stats module. CLI core_ci guide and script in place. 2025-08-26 01:42:18 +09:00
7705508b99 9.78h mainline: add TypeOp mixed-case MIR snapshot and include in CI golden checks; VM module headers for AI-friendly navigation; CURRENT_TASK updated with refactor goals. 2025-08-26 01:09:17 +09:00
7ccd5420ac Docs/CurrentTask: add explicit refactor goals/milestones/steps. VM modules: add Purpose/Responsibilities/Key APIs/Typical Callers headers. Build+goldens green. 2025-08-26 01:07:23 +09:00
edadf67ca0 Refactor (structure): add vm_stats module; move BoxCall debug logger into vm_boxcall; add quick-reference/code-map.md for AI-friendly repo navigation. Keep behavior unchanged. 2025-08-26 00:58:57 +09:00
2a02eb7a52 Refactor (light): move VM value ops to backend/vm_values.rs; add backend/vm_boxcall.rs with call_box_method_impl and rewire call_unified_method. Update CURRENT_TASK for refactor start. 2025-08-26 00:48:09 +09:00
320fbf0955 Phase 9.78h: Expand MIR golden snapshots (extern_call, loop, boxcall); add extern_console_log test; update CI golden check. Report refactoring candidates >1000 lines. 2025-08-26 00:12:53 +09:00
f82ad5a84d Phase 9.78h: VM BinOp and/or short-circuit + BoxRef<Integer> arithmetic; add diagnostic hooks. Update CURRENT_TASK with progress and VM path-tracing TODO. Align docs: MIR26 canonical spec and phase docs. 2025-08-26 00:06:35 +09:00
b8e416fb03 refactor: MIR builder modularization complete - ready for handoff
- MIRビルダーのモジュール化完了(1,547行→6モジュール)
  - core.rs (205行): MirBuilder本体
  - expressions.rs (621行): 式変換処理
  - statements.rs (165行): 文変換処理
  - control_flow.rs (194行): 制御フロー
  - box_handlers.rs (73行): Box処理
- 現在builder_modularizedに退避(MIR命令構造変更により調整必要)
- フルビルド可能な状態を維持
- CURRENT_TASK.mdに引き継ぎポイント記載

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 19:33:07 +09:00
4caa07d865 docs: Update CURRENT_TASK.md after MIR builder refactoring completion
- Marked MIR builder modularization as completed
- Added completion dates and commit hashes
- Updated next priority tasks from copilot_issues.txt
- Cleaned up completed task descriptions
2025-08-25 19:09:29 +09:00
17adc4347d refactor: MIR builder - complete modularization (Phase 6-8)
- Phase 6: statements.rs (165 lines) - 6 functions
  - build_print_statement, build_block
  - build_local_statement, build_return_statement
  - build_throw_statement, build_nowait_statement

- Phase 7: control_flow.rs (194 lines) - 4 functions
  - build_if_statement, build_loop_statement
  - build_try_catch_statement, is_current_block_terminated

- Phase 8: box_handlers.rs (73 lines) - 2 functions
  - build_static_main_box, build_box_declaration

Total: 30 functions moved across 4 modules
Original builder.rs reduced from 1547 lines
Build verified successfully
2025-08-25 18:43:45 +09:00
4b984d937b refactor: MIR builder - extract expressions module (Phase 3-5)
- Moved all expression-related functions to expressions.rs (621 lines)
- Includes: build_expression, build_literal, binary/unary ops
- Added missing functions for build_expression completeness:
  - build_assignment, build_field_assignment
  - build_new_expression, build_await_expression
- expressions.rs now contains 16 functions total
- Build verified successfully
2025-08-25 18:15:23 +09:00
cff58dbc0a refactor: MIR Builder Phase 1 - モジュール分割準備完了
【Phase 1完了内容】
- src/mir/builder/ ディレクトリ構造作成
- MirBuilder コア機能を core.rs に分離(8関数実装済み)
- 責務別モジュール準備(expressions/statements/control_flow/box_handlers)
- ビルド確認: 新構造でコンパイル正常完了

【技術詳細】
- MirBuilder本体 + emit_instruction/emit_type_check等コア機能
- プレースホルダー実装でビルド安全性確保
- CURRENT_TASK.md更新(Phase 1完了状況記録)
- 49関数/1547行の段階的分割準備

【次のPhase】
- Phase 2: 実際の関数移動(expressions.rs最優先)
- 慎重アプローチ: デッドコード削除は後回し

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 17:49:21 +09:00
c6d3b954d5 feat: Add dual-mode design doc and VM/MIR improvements
- Add comprehensive dual-mode design document (script vs application mode)
- Update phase 9.8 documentation with implementation progress
- Enhance VM with improved error handling and debugging
- Add MIR verification improvements
- Add test cases for MIR/VM POC

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-24 02:52:11 +09:00
0aef8d49a7 Phase 2: TypeOp変換の一本化(Optimizer安全ネット削除)\nPhase 3: 可視化/スナップショット基盤(--mir-verbose-effects, snapshot/compare/ci_check)\nDocs: Phase 1/2 完了マーク・利用方法追記 2025-08-24 01:58:41 +09:00
3c3dc86be0 feat: MIR builder TypeOp lowering for is/as methods and isType/asType functions
- Add early TypeOp lowering in build_expression for method-style is()/as()
- Add early TypeOp lowering in build_expression for function-style isType()/asType()
- Add special handling in build_print_statement for print(isType/asType(...))
- Fix MIR optimizer borrow checker issues and remove obsolete BoxFieldLoad
- Extract string literal helper supports both direct literals and StringBox wrappers
- Note: isType call generation still has issues (undefined SSA value in print)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-24 00:05:12 +09:00
2949648e71 fix: MIR builder me resolution for static box methods
- Fixed me ValueId inconsistency in static box methods
- Previously, each me reference generated a new const __me__ ValueId
- Now caches the first me ValueId in variable_map for reuse
- This ensures RefSet and RefGet operate on the same object
- ArrayBox get/set/push now working correctly in VM mode
- Test results: 1, 42, 3 (as expected)

🔧 Technical Details:
- build_me_expression() now stores fallback ValueId in variable_map
- Subsequent me references reuse the same ValueId
- VM BoxCall debug logs confirm ArrayBox methods dispatch correctly

Co-Authored-By: ChatGPT5
Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 21:13:02 +09:00
fffbac9aac feat: MIR TypeOp/WeakRef/Barrier PoC implementation
- Add TypeOpKind, WeakRefOp, BarrierOp enums for unified instructions
- Implement TypeOp instruction combining TypeCheck/Cast
- Implement WeakRef instruction combining WeakNew/WeakLoad
- Implement Barrier instruction combining BarrierRead/BarrierWrite
- Update VM to handle new unified instructions
- Update MIR printer for new instruction formats
- Add feature flags mir_typeop_poc and mir_refbarrier_unify_poc
- Maintain backward compatibility with legacy instructions

This is Phase 8.5 MIR instruction diet PoC implementation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 19:27:02 +09:00
98fd6a1e3e docs: Update CURRENT_TASK with VM enhancements and test results
- Document dynamic type conversion implementations
- Add test results for Integer non-zero conditions
- Update ArrayBox/MapBox VM method support status
- Record SocketBox timeout method implementations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:52:18 +09:00
ff14d489d3 feat: Enhance VM with dynamic type conversion and comprehensive method support
- Add dynamic bool conversion for BoxRef(BoolBox)→bool and BoxRef(VoidBox)→false
- Implement String concatenation with Bool and BoxRef types via toString()
- Add Void/Bool comparison support (Eq/Ne only) to prevent VM crashes
- Implement comprehensive ArrayBox methods in VM:
  - push/pop/length/get/set/remove
  - contains/indexOf/clear/join/sort/reverse/slice
- Implement comprehensive MapBox methods in VM:
  - set/get/has/delete/keys/values/size/clear
- Add SocketBox timeout methods (acceptTimeout/recvTimeout)
- Update VM documentation with all new operations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:37:38 +09:00
70af0fe566 feat: Add HTTP status tests and dynamic plugin documentation
- Add e2e_vm_http_status_404/500 tests to verify HTTP status handling
- ResultBox properly returns Ok(Response) for HTTP errors, Err for connection failures
- Create dynamic-plugin-flow.md documenting MIR→VM→Registry→Plugin flow
- Add vm-stats test files for HTTP 404/500 status codes
- Update net-plugin.md with HTTP error handling clarification
- Create E2E_TESTS.md documenting all E2E test behaviors
- Add mir-26-instruction-diet.md for MIR optimization plans
- Add vm-stats-cookbook.md for VM statistics usage guide
- Update MIR verifier to properly track self-assignment patterns

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 16:33:32 +09:00
3b03d001ba feat: Complete VM plugin E2E tests with ResultBox support
 All E2E tests passing:
- e2e_vm_plugin_filebox_copy_from_handle: Handle arguments (tag=8) working
- e2e_vm_http_get_basic: GET with ResultBox.get_value() working
- e2e_vm_http_post_and_headers: POST with status/headers/body verified (201:V:R)

Key achievement:
- VM already had ResultBox methods (is_ok/get_value/get_error) implemented
- HTTP plugin methods now correctly return values through ResultBox
- Full VM×Plugin integration verified

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 05:27:18 +09:00
63749b683e feat: Add VM statistics and fix compilation errors for plugin tests
- Add VM instruction statistics (--vm-stats, --vm-stats-json)
- Fix missing fields in ast.rs test code (public_fields, private_fields)
- Add CliConfig fields for VM statistics
- Enable TLV debug logging in plugin_loader_v2
- Successfully test FileBox handle passing and HTTP plugin creation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 04:51:24 +09:00
dd09e81018 feat: Add VM instruction statistics and fix plugin TLV debugging
Major changes:
- Add --vm-stats and --vm-stats-json CLI flags for VM instruction profiling
- Implement instruction counting by opcode type with JSON output support
- Add enhanced TLV debug logging with NYASH_DEBUG_PLUGIN=1 environment variable
- Fix missing fields in CliConfig and ASTNode::BoxDeclaration for test compatibility
- Improve plugin method call error messages with argument count/type details

This enables MIR→VM conversion health checks and supports the Phase 8.6 VM optimization goals.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 03:40:17 +09:00
4760921e91 feat: Add enhanced debug logging for plugin VM communication
- Add VM→Plugin and Plugin→VM boundary logging for method calls
- Enhanced debug output for tracking plugin invocation flow
- Added return value type/instance logging for better debugging
- Improved plugin communication traceability

This helps debug issues like the recent 45-day HTTP response debugging saga.
All logging is controlled by NYASH_DEBUG_PLUGIN=1 environment variable.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 12:36:14 +09:00
080458d4d4 fix: Correct HttpRequestBox method_id mapping in nyash.toml
Fixed the method ID order in HttpRequestBox configuration to match plugin implementation:
- path: method_id 1 (was incorrectly 2)
- readBody: method_id 2 (was incorrectly 3)
- respond: method_id 3 (was incorrectly 1)

This resolves the 45-day debugging issue where req.respond(resp) was calling
the wrong plugin method, causing HTTP responses to have empty bodies.

All E2E tests now pass:
- e2e_http_stub_end_to_end 
- e2e_http_multiple_requests_order 
- e2e_http_post_and_headers 
- e2e_http_server_restart 
- e2e_http_server_shutdown_and_restart 

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 12:09:06 +09:00
ce9e60972a feat: Add returns_result support and when pattern-matching design
- Add returns_result.md documenting Result正規化 (returns_result = true)
- Add when-pattern-matching.md with future pattern matching syntax design
- Update E2E tests to use get_value() for HTTP responses
- Update plugin system README with B案 (Result-based) support
- Remove singleton from HttpServerBox and SocketServerBox for stability

This prepares for gradual migration to Result-based error handling,
starting with Net plugin methods, as agreed with ChatGPT5's design.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 06:05:58 +09:00
f2761004d3 feat: Add parallel HTTP server E2E tests and enhance plugin system
- Add e2e_plugin_net_additional.rs with parallel server tests
- Fix test to properly handle request objects (no double accept)
- Add comprehensive net-plugin documentation
- Implement debug tracing for method calls
- Enhance plugin lifecycle documentation
- Improve error handling in plugin loader
- Add leak tracking infrastructure (for future use)
- Update language spec with latest plugin features

This enhances test coverage for concurrent HTTP servers and improves
the overall plugin system documentation and debugging capabilities.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 05:01:11 +09:00
eae7f54b13 feat: Add HTTP server/client E2E test for net plugin
- Implement full HTTP flow test: server → client → accept → respond → readBody
- All HTTP Box types working correctly (HttpServerBox, HttpClientBox, HttpRequestBox, HttpResponseBox)
- Handle type encoding for plugin method arguments working properly
- Test validates complete HTTP request/response cycle
- Net plugin E2E test passing 

HTTPネットワークプラグインのE2Eテスト追加
- サーバー起動からレスポンス読み取りまでの完全なフロー検証
- Handle型引数のTLVエンコーディングも正常動作
- 非同期HTTPフローの完全動作確認

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 22:25:42 +09:00
da716addc8 feat: Implement plugin singleton pattern with shutdown support
- Add singleton support for plugin boxes (e.g., CounterBox)
- Implement shutdown_plugins_v2() for controlled plugin lifecycle
- Plugin instances now shared across multiple new() calls
- Shutdown properly releases and allows re-initialization
- All singleton E2E tests passing 

ChatGPT5による高度なプラグインライフサイクル管理実装
- シングルトンパターンでプラグインインスタンス共有
- 明示的なshutdownでリソース解放と再初期化対応
- Nyashの統一ライフサイクルポリシー維持

Note: ast.rs test failures are due to rapid development pace -
tests need updating for new BoxDeclaration fields (private_fields, public_fields)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 21:35:17 +09:00
11c8672252 feat: Complete internal field access identification for visibility system
- Add internal access tracking to distinguish me.field from external.field access
- Interpreter correctly allows methods to access their own private fields
- VM tracks object class context during method calls for visibility checks
- Fix VM nested box declaration collection in collect_box_declarations
- Both interpreter and VM now pass all visibility tests consistently

Test results:
- visibility_ok.nyash:  Internal private access allowed in methods
- visibility_error.nyash:  External private access correctly blocked
- All private fields accessible from within their own methods
- Public fields remain accessible from anywhere

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 03:42:20 +09:00
55777a0735 feat: Implement field visibility (public/private) system
## Major Features Added

### Field Visibility System
- Added `private { ... }` and `public { ... }` blocks in box declarations
- Default visibility is now handled explicitly (fields must be in either block)
- Visibility checks enforced at both interpreter and VM levels

### Parser Enhancements
- Extended AST with public_fields and private_fields vectors
- Added parsing for visibility blocks in box definitions
- Maintained backward compatibility with existing `init { ... }` syntax

### Interpreter Implementation
- Added visibility checks in field access (get_field/set_field)
- External access to private fields now throws appropriate errors
- Internal access (within methods) always allowed

### VM Implementation
- Extended VM with object_class tracking for visibility checks
- RefGet/RefSet instructions now enforce field visibility
- Fixed nested box declaration collection (boxes defined inside methods)

### Test Examples Added
- docs/examples/visibility_ok.nyash - demonstrates correct usage
- docs/examples/visibility_error.nyash - tests private field access errors

## Technical Details

### Error Messages
- Interpreter: "Field 'X' is private in Y"
- VM: Same error message for consistency

### Current Limitations
- All RefGet/RefSet treated as external access in VM (internal flag future work)
- Legacy `init { ... }` fields treated as having unspecified visibility

## Test Results
 Interpreter: Both test cases pass correctly
 VM: Both test cases pass correctly after nested declaration fix

This implements the foundation for proper encapsulation in Nyash,
following the "explicit is better than implicit" philosophy.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 03:08:13 +09:00
2200312f09 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>
2025-08-21 01:18:25 +09:00
cc2a820af7 feat(plugin): Fix plugin BoxRef return and Box argument support
- Fixed deadlock in FileBox plugin copyFrom implementation (single lock)
- Added TLV Handle (tag=8) parsing in calls.rs for returned BoxRefs
- Improved plugin loader with config path consistency and detailed logging
- Fixed loader routing for proper Handle type_id/fini_method_id resolution
- Added detailed logging for TLV encoding/decoding in plugin_loader_v2

Test docs/examples/plugin_boxref_return.nyash now works correctly:
- cloneSelf() returns FileBox Handle properly
- copyFrom(Box) accepts plugin Box arguments
- Both FileBox instances close and fini correctly

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 00:41:26 +09:00
dce53bf683 feat(phase-9.78b): Complete plugin Box inheritance and argument support
ChatGPT5による大規模改善:
-  プラグインBox継承サポート完成
-  from Parent.method()でプラグインメソッド呼び出し
-  引数・戻り値のTLVエンコード/デコード
-  借用チェッカーエラー全解決
-  MIRビルダーのクローン修正

次期作業:
- Phase 9.78b Step 3: BoxFactory dyn化
- アーキテクチャ改善継続

Co-authored-by: ChatGPT5 <noreply@openai.com>
2025-08-20 20:56:08 +09:00
8aef29eaef 🎉 feat: MIRパラメータ解決完全修正 + VM E2Eテスト成功!
Phase 9.78b関連修正:
- MirBuilder::lower_method_as_function でValueIdリセット実装
  - me → %0, 引数 → %1... の正しいマッピング
- build_me_expression() で変数テーブル優先解決
- VM E2Eテスト test_vm_user_box_birth_and_method 成功
  - new Person("Alice").greet() → "Hello, Alice"

ドキュメント:
- mir-unified-reference.md を正式MIRドキュメントとして配置
  - 現在の35命令実装状態を正確に記載
  - RefGet/RefSet仕様含む

ChatGPT5によるMIRビルダー修正で、VMバックエンドでのユーザー定義Box完全動作!
2025-08-20 19:34:09 +09:00
41361a2f50 🚀 feat: Phase 9.78b Step 1&2完了 - ChatGPT5による実装
ChatGPT5が実装したPhase 9.78b Step 1&2の統合

## 🎯 実装内容
1. Phase 9.78b Step 1: BoxDeclarationをcore::modelへ移動
   - src/core/mod.rs, model.rs 新規作成
   - BoxDeclarationを純粋データモデルとして分離

2. Phase 9.78b Step 2: NyashRuntime骨組み作成
   - src/runtime/nyash_runtime.rs 追加
   - 統一Box管理の基盤

3. ビルドエラー修正
   - Arc重複インポート修正
   - as_str() → as_ref() 変更
   - parent_name.to_string() 型変換
   - インポートパス調整

## 📊 ビルド結果
-  フルビルド成功 (47.34秒)
-  ユニットテスト: 145/145成功
-  統合テスト: 16/16成功
-  WASMビルド成功 (1.9MB)
-  MIRテスト: 1失敗 (ref_new命令)

## 🚀 次のステップ
- Phase 9.78b Step 3: BoxFactory dyn化
- Codexの設計に基づく段階的実装継続
2025-08-20 18:57:10 +09:00
86b9f7719b 🏗️ feat: Phase 9.78b準備 - インタープリター・VM統合アーキテクチャ設計
Phase 9.78b: Codexの天才的分析に基づくアーキテクチャ再設計準備

## 📋 実施内容
1. Codex分析結果のアーカイブ
   - 実装詳細共有 → モデル共有・実行時共有への転換提案
   - 8ステップの段階的実装計画

2. Phase 9.78a作業の保存
   - MIR生成でのNewBox命令統一(保持)
   - ScopeTracker基本実装(一時コメントアウト)
   - VM拡張の方向性(TODOコメント付き)

3. ビルドエラー修正
   - ScopeTrackerインポート問題を一時的に解決
   - ビルド成功(警告のみ)

## 📚 作成ドキュメント
- architecture-redesign-proposal.md - Codexの設計提案
- phase_9_78b_interpreter_architecture_refactoring.md - 実装計画
- codex-analysis/* - 分析結果アーカイブ

## 🎯 次のステップ
Phase 9.78b Step 1: BoxDeclarationをcore::modelへ移動
2025-08-20 17:58:51 +09:00
c11b68af90 📝 docs: Phase 9.78a実装箇所詳細分析追加
## 🔍 実装箇所の詳細分析
- MIR生成部分: build_new_expression()でRefNew→NewBox修正
- VM実行部分: 主要な修正箇所(BoxFactory統合、スコープ管理)
- 共有コンポーネント: BoxFactory、InstanceBoxをVMでも使用

## 📋 CURRENT_TASK.md更新
- Phase 9.78a VM統一Box処理の実装ステップ詳細化
- Step 1-5の具体的な実装内容を明記
- 関連ドキュメントへのリンク追加

次はStep 1のMIR生成修正から実装開始!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 16:08:22 +09:00
59cae9fe2a 📚 docs: VM Plugin System統合の完全設計
Phase 9.78a: VM統一Box処理アーキテクチャ

## 🎯 解決した問題
- ユーザー定義Box未対応 → BoxFactory統合で解決
- birth/finiライフサイクル欠落 → ScopeTracker実装で解決
- メソッド呼び出しハードコード → 統一ディスパッチで解決

## 📚 作成したドキュメント
- Phase 9.78a VM Plugin Integration計画書
- Phase 9.78a 深層分析(インタープリター比較)
- VM Plugin Integration仕様書(統一アーキテクチャ)

## 🌟 統一設計の核心
Everything is Box + 統一ライフサイクル
- すべてのBox型(ビルトイン/ユーザー定義/プラグイン)が同じ扱い
- birth → 使用 → fini の一貫性
- シンプルで保守しやすい実装

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 15:58:28 +09:00
69a07cbb1f fix: fini後のアクセスエラーを削除(ユーザー要求対応)
ユーザーからの明確な要求「finiは何回呼ばれてもエラーにならないしよう」に従い、
fini後のインスタンスアクセスを禁止するエラーチェックをすべて削除しました。

変更内容:
- interpreter/statements.rs: is_finalized()チェック削除(3箇所)
- interpreter/field_access.rs: is_finalized()チェック削除
- interpreter/expressions/calls.rs: is_finalized()チェック削除
- interpreter/expressions/access.rs: is_finalized()チェック削除

動作確認:
- test_fini_multiple_calls.nyash: finiを3回呼んでもエラーなし
- fini後のフィールドアクセスも正常動作
- CHIP-8エミュレータも正常動作

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 14:34:46 +09:00
3e8b75f4de fix: Kilo/CHIP-8アプリエラー修正 - toInteger, substring, レガシーBox削除
## 修正内容
1. **toIntegerメソッド実装** (#125)
   - StringBoxにtoInteger()メソッド追加
   - box_trait::IntegerBoxを返すよう統一(レガシーboxes::IntegerBox削除)

2. **substringメソッド実装**
   - StringBoxにsubstring(start, end)メソッド追加
   - Kiloエディタで必要な文字列操作を完全サポート

3. **レガシーコード削除**
   - src/boxes/mod.rsから重複StringBox/IntegerBox/BoolBoxエクスポート削除
   - 全てbox_trait実装に統一

4. **プラグインドキュメント整理**
   - 古い仕様書に「理想案・未実装」「将来構想」明記
   - 実装ベースの正確な仕様書作成
   - migration-guide.md追加

## テスト結果
-  Kiloエディタ: 完全動作確認("Enhanced Kilo Editor test complete")
-  toInteger()の乗算: 正常動作
-  substring(): 正常動作

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 14:13:47 +09:00
670615d1de feat: WASMビルド完全対応+finiシステム修正 🎉
## WASMビルド対応
- TimerBox、AudioBox等の問題のあるBoxをWASM環境では条件付きコンパイルで除外
- WebBox (WebDisplayBox, WebConsoleBox, WebCanvasBox) にas_anyメソッド追加
- プラグイン関連コードに#[cfg]ガードを追加
- web-sysフィーチャーを追加(Performance、MouseEvent等)
- projects/nyash-wasmのビルドが完全に通るように!

## finiシステム修正
- フィールド差し替え時の自動fini削除(Nyashの明示的哲学に従う)
- スコープ離脱時のみfini実行(meは除外)
- ドキュメント更新で正しいfiniルールを明記

## その他
- CLAUDE.mdにWASMビルド方法を追記(wasm-pack build --target web)
- 開発サーバー起動方法を記載(python3 -m http.server 8010)
- cargo testで全テスト成功を確認

これでNyashがブラウザで動作可能に!🐱

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 07:33:18 +09:00
83d3914e46 🚨 fix: フィールド差し替え時の危険な自動fini呼び出しを発見
現在の問題:
- me.field = newValue で古いfieldのfiniが自動で呼ばれる
- 共有参照を破壊する可能性(複数から参照されている場合)
- GC的な「おせっかい」でNyashの明示的哲学に反する

次の修正予定:
- フィールド差し替え:fini呼ばない(プログラマー責任)
- スコープ離脱時:fini呼ぶ(自然なリソース管理)
- Everything is Explicit の哲学を貫く

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 05:57:18 +09:00
9eb52982b5 fix: Phase 9.78e+: Fix birth constructor and builtin Box method inheritance
🌟 Major fixes:
- Fix birth constructor lookup (was searching for 'init/N', now 'birth/N')
- Fix builtin Box method inheritance via __builtin_content field
- Remove InstanceBox wrapping for builtin Boxes
- Update execute_builtin_birth_method to properly store builtin content
- Update method resolution to check __builtin_content for builtin methods

 All tests pass:
- Birth constructors work correctly
- User-to-user Box delegation works
- User-to-builtin Box delegation works (toString() properly inherited)
- Apps folder tested (chip8, kilo editor run successfully)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 02:19:59 +09:00
164f1079ec 🏆 LEGENDARY: birth構文革命+デリゲーション完全勝利!
🌟 **birth構文完全修復** - Everything is Boxの究極実現
- objects.rs 2箇所の重要修正: init → birth統一完了
- 引数付きコンストラクタ完全動作: birth(args) 
- 統一レジストリとの完全連携: InstanceBox統合 
- テスト結果: 🌟 TestBox誕生完全成功!

🔄 **デリゲーション透過完全成功** - 美しい継承システム実現
- box Child from Parent: デリゲーション宣言 
- from Parent.birth(args): 親コンストラクタ透過呼び出し 
- override + from Parent.method(): 完璧な継承階層 
- テスト結果: 親子デリゲーション完全動作確認!

🎮 **実用アプリ動作確認完了**
- CHIP-8エミュレーター: パース成功+実行開始 
- Kiloテキストエディター: birth構文で初期化成功 
- Proxyサーバー: デリゲーション機能動作確認 

🎯 **Phase 9.78e PLUS達成**
- instance_v2移行 100% 完了
- birth構文革命 100% 完了
- デリゲーション透過 100% 完了
- Everything is Box哲学完全実現

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 00:58:35 +09:00
94e646ebc4 feat: Phase 9.78e完全勝利!instance_v2移行100%成功
🎉 **InstanceBoxラップ演算子問題完全解決**
- unwrap_instanceヘルパー関数実装で型地獄回避
- 4つの演算子関数修正(add/sub/mul/div)
- StringBox + IntegerBox混在演算子完全動作

🚀 **Everything is Box哲学完全実現**
- 全Box型(ビルトイン、ユーザー定義、プラグイン)統一アーキテクチャ
- InstanceBoxによる完全統一ラッピング
- シンプルで保守可能な実装

 **全機能動作確認済み**
- Person/Employee作成・デリゲーション完全動作
- フィールドアクセス・メソッドオーバーライド成功
- 統一レジストリ完全統合

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 00:43:35 +09:00
e5e381aa83 feat: Implement Phase 9.78e instance_v2 migration with unified registry
Major achievements:
-  UserDefinedBoxFactory implementation with unified registry integration
-  Constructor execution for user-defined boxes (Person init working)
-  Import path fixes across interpreter modules
-  unwrap_instance helper function for InstanceBox operator support

Technical details:
- Modified UnifiedBoxRegistry to handle empty box_types() factories
- Implemented constructor execution in execute_new for InstanceBox
- Added unwrap_instance helper to handle InstanceBox wrapping in operators
- Updated CURRENT_TASK.md with detailed progress tracking

Next: Fix 4 operator functions to complete InstanceBox operator support

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 00:21:20 +09:00
5a50cf6415 feat(phase-9.78e): Complete instance_v2 migration - remove instance.rs entirely
🎉 Victory\! instance.rs (v1) has been completely removed\!

Changes:
- Delete src/instance.rs
- Remove 'pub mod instance;' from lib.rs and main.rs
- instance_v2 is now the only InstanceBox implementation
- Library builds successfully without instance.rs

Technical notes:
- Legacy compatibility layer remains in instance_v2 for smooth transition
- Type conversion TODOs remain (SharedNyashBox <-> NyashValue)
- Binary builds still have import path issues to fix later
- Basic functionality fully operational with instance_v2

🎯 Phase 9.78e complete: instance_v2への完全移行成功!
2025-08-19 22:45:47 +09:00
5582ad45c0 feat: Phase 9.78e complete - instance_v2 migration with legacy compatibility
- instance_v2 now includes legacy compatibility layer
- All interpreter code migrated to use instance_v2
- Added legacy field access methods (get_fields, set_field_legacy, etc.)
- Fixed type conversion issues (NyashValue vs SharedNyashBox)
- instance.rs still exists but no longer used in interpreter
- TODO: Remove instance.rs completely in next phase
- TODO: Implement proper SharedNyashBox -> NyashValue conversion

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 22:35:34 +09:00
3ae4ae8211 docs: Phase 9.78e動的メソッドディスパッチの状況と型変換問題、ラッパー戦略決定 2025-08-19 21:10:00 +09:00