Commit Graph

13 Commits

Author SHA1 Message Date
aacce00c38 refactor: remove legacy files and redundant delegation (-2997 lines)
Removed unused legacy code identified by comprehensive codebase analysis:

Phase 1 Deletions:
- src/parser/statements_backup.rs (723 lines)
  Reason: Refactoring to statements/ module complete, no references

- src/runtime/plugin_box_legacy.rs (158 lines)
  Reason: Completely unused, zero references in codebase

- tools/plugin-tester/src/main_old.rs (787 lines)
  Reason: Old version, no references in Cargo.toml or mod.rs

- src/llvm_py/instructions/mir_call.py.bak (1,321 lines)
  Reason: Backup file, not tracked by git

- src/mir/optimizer_passes/normalize_legacy_all.rs (8 lines)
  Reason: Pure delegation wrapper, function available in normalize.rs
  Updated: src/mir/optimizer_passes/mod.rs (removed module declaration)

Total Impact:
- Lines deleted: 2,997
- Files removed: 5
- Risk: Zero (all verified as unreferenced)
- Build: Successful (cargo build --release confirmed)

Analysis Report:
- Task subagent verified zero references via grep -r
- Compilation check: All modules build without errors
- Refactoring context: statements/ module completed 2025-10-01

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 12:19:17 +09:00
73b90a7c28 feat: スモークテストv2実装&Phase 15.5後のプラグイン対応
Phase 15.5 Core Box削除後の新テストシステム構築:

## 実装内容
- スモークテストv2システム完全実装(3段階プロファイル)
- 共通ライブラリ(test_runner/plugin_manager/result_checker/preflight)
- インタープリター層完全削除(約350行)
- PyVM重要インフラ特化保持戦略(JSON v0ブリッジ専用)
- nyash.tomlパス修正(13箇所、プラグイン正常ロード確認)

## 動作確認済み
- 基本算術演算(+, -, *, /)
- 制御構文(if, loop, break, continue)
- 変数代入とスコープ
- プラグインロード(20個の.soファイル)

## 既知の問題
- StringBox/IntegerBoxメソッドが動作しない
  - オブジェクト生成は成功するがメソッド呼び出しでエラー
  - Phase 15.5影響でプラグイン実装が不完全な可能性

## ドキュメント
- docs/development/testing/smoke-tests-v2.md 作成
- docs/reference/pyvm-usage-guidelines.md 作成
- CODEX_QUESTION.md(Codex相談用)作成

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 09:30:42 +09:00
11506cee3b Phase 11-12: LLVM backend initial, semantics layer, plugin unification
Major changes:
- LLVM backend initial implementation (compiler.rs, llvm mode)
- Semantics layer integration in interpreter (operators.rs)
- Phase 12 plugin architecture revision (3-layer system)
- Builtin box removal preparation
- MIR instruction set documentation (26→Core-15 migration)
- Cross-backend testing infrastructure
- Await/nowait syntax support

New features:
- LLVM AOT compilation support (--backend llvm)
- Semantics layer for interpreter→VM flow
- Tri-backend smoke tests
- Plugin-only registry mode

Bug fixes:
- Interpreter plugin box arithmetic operations
- Branch test returns incorrect values

Documentation:
- Phase 12 README.md updated with new plugin architecture
- Removed obsolete NYIR proposals
- Added LLVM test programs documentation

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 23:44:34 +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
806aece8ad refactor: Begin migration to nyash.toml v2 plugin system
- Rename legacy plugin files to *_legacy.rs for protection
- Comment out old plugin loader and Host VTable dependencies
- Add temporary stub for create_plugin_box during migration
- Fix doc comment placement in io_methods.rs
- Prepare for v2 plugin system with single FFI entry point
2025-08-19 05:05:21 +09:00
e1b148051b feat: nyash.toml v2完全対応とinit関数オプション化
主な変更:
- nyash.toml v2形式(マルチBox型プラグイン)に完全対応
- plugin-testerをv2対応に全面更新
- Host VTable完全廃止でシンプル化
- init関数をオプション化(グローバル初期化用)
- FileBoxプラグインを新設計に移行(once_cell使用)

仕様更新:
- nyash_plugin_invoke(必須)とnyash_plugin_init(オプション)の2関数体制
- すべてのメタ情報はnyash.tomlから取得
- プラグインは自己完結でログ出力

テスト確認:
- plugin-testerでFileBoxの動作確認済み
- birth/finiライフサイクル正常動作

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 04:48:25 +09:00
cc8553380c feat: Add multi-box plugin support (v2) with test implementation
- Extend plugin-tester to support multi-box plugins with v2 API
- Add nyash_plugin_get_box_count/get_box_info/get_type_id functions
- Create test multi-box plugin providing TestBoxA and TestBoxB
- Update plugin-system.md documentation for v2 format
- Add nyash.toml v2 specification for multi-box support
- Successfully tested multi-box plugin lifecycle and type resolution

This enables one plugin to provide multiple Box types, solving the
dependency issue where HTTPServerBox needs SocketBox.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 01:13:48 +09:00
bfb2d648d5 feat(phase-9.75g-0): Complete BID-FFI Plugin System with enhanced plugin-tester
🎊 Phase 9.75g-0 COMPLETE - Revolutionary Plugin System Achievement\!

 Major Completions:
- plugin-tester type validation: nyash.toml integration & method signature verification
- Duplicate method name detection: Enforces Nyash no-overloading policy
- Comprehensive developer guide: 200+ line technical documentation
- Memory safety: HostVtable lifetime issues resolved with LazyLock
- Type information system: External nyash.toml configuration eliminates hardcoded conversions

🚀 Revolutionary Impact:
Nyash now supports dynamic Box type extension via plugins:
```nyash
local file = new FileBox()        // Plugin-provided
local db = new PostgreSQLBox()    // Future: Plugin-provided
local gpu = new CudaBox()         // Future: Plugin-provided
```

📊 Technical Achievements:
- plugin-tester: 4 comprehensive validation modes (check/lifecycle/io/typecheck)
- BID-FFI Protocol: Production-ready with valgrind-verified memory safety
- Type conversion: Automatic string→bytes mapping via nyash.toml
- Method validation: Prevents overloading conflicts in plugin development

🎯 Next Priority: Phase 8.6 VM Performance Improvement
Current issue: VM is 0.9x slower than interpreter (regression\!)
Target: 2x+ speedup for practical VM execution

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 16:04:30 +09:00
c6c3c8e2f9 fix(bid-ffi): Fix HostVtable lifetime issue causing segfault
🚨 Critical memory safety fix:
- HostVtable was created on stack and destroyed after init
- Plugin stored reference to destroyed memory → NULL pointer access
- Changed to static LazyLock storage for lifetime safety

 Results:
- Segfault completely eliminated
- Plugin logging now works properly
- Type info system confirmed working
- Full E2E FileBox plugin operation successful

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 14:10:41 +09:00
f5ab4910e4 fix(plugins): Fix FileBox plugin I/O operations and add TLV debugging
## FileBox Plugin Fixes

### Issue Resolution
- Fixed file write operations not persisting to disk
- Fixed TLV tag mismatch preventing read operations
- Added comprehensive TLV debugging capability

### Changes Made

#### plugins/nyash-filebox-plugin/src/lib.rs
- Added file.flush() after write operations to ensure data persistence
- Modified tlv_parse_bytes to accept both String(6) and Bytes(7) tags
- Resolves compatibility issue with plugin-tester String encoding

#### tools/plugin-tester/src/main.rs
- Added `tlv-debug` subcommand with detailed TLV analysis
- Provides hex dumps, encoding/decoding verification
- Full plugin round-trip testing with file I/O validation
- Detailed error analysis for debugging TLV protocol issues

## Test Results

### Before Fix
```
INFO: WRITE 8 bytes
INFO: READ 0 bytes  ← Problem: no data read
✗: Plugin round-trip failed\!
```

### After Fix
```
INFO: WRITE 8 bytes
INFO: READ 8 bytes  ← Fixed: data successfully read
✓: Plugin round-trip successful\!
```

## Technical Details
- Root cause: Missing file.flush() + TLV tag type mismatch
- Plugin-tester sends String(6), plugin expected Bytes(7) only
- File buffer not flushed to disk before close/reopen
- Solution: Added flush() + dual tag support for compatibility

This completes the core BID-FFI plugin I/O functionality validation.
Nyash integration still needs method dispatch optimization.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 11:21:04 +09:00
0441608db3 BID-FFI integration:\n- Add plugin-tester io subcommand and TLV helpers; E2E open/write/read/close\n- Implement FileBox plugin invoke (birth/open/read/write/close) with BID-1 two-pass\n- Add BID loader/registry/plugin_box modules; prefer plugin-backed FileBox in interpreter\n- Introduce PluginFileBox with minimal read/write/close dispatch\n- Update runner debug paths; add local simple tests\n- Docs: plugin-tester guide and FileBox Nyash↔BID mapping; CURRENT_TASK updated 2025-08-18 11:07:03 +09:00
2efdd0ac0c feat: BID-FFIプラグインシステム基盤実装(Step 1-3完了)
- FileBoxプラグイン単体実装
  - birth/finiライフサイクル対応
  - 6つのメソッド定義(birth/open/read/write/close/fini)
  - プラグインが自らBox名「FileBox」を宣言

- nyash.toml設定ファイル作成
  - FileBox = "nyash-filebox-plugin" マッピング定義
  - プラグイン検索パス設定

- プラグインテスター作成(tools/plugin-tester)
  - Box名を決め打ちしない汎用設計
  - プラグインから型情報を動的取得
  - メソッド一覧表示機能
  - 診断機能付きチェックコマンド

重要な設計原則:
- プラグインが自分のBox名を宣言(ローダーは知らない)
- 汎用的で拡張可能な設計
- メモリ管理の明確な責任分担

次のステップ:Nyashとの統合(Step 4)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 09:32:54 +09:00