Commit Graph

9 Commits

Author SHA1 Message Date
06a729ff40 vm(hako): add v1 reader/dispatcher (flagged), commonize mir_call handler, share block scan; smokes: add v1 hakovm canary; docs: 20.37/20.38 plans, OOB policy; runner: v1 hakovm toggle; include SKIP summary 2025-11-03 23:21:48 +09:00
83db6a715c refactor(vm): Phase 5 - Call Resolution extraction (49行削減)
【目的】
execute_legacy_call関数の肥大化解消、保守性向上

【実装内容】
1. call_resolution.rsの新規作成(87行)
   - resolve_function_name() ヘルパー関数
   - unique-tail matching algorithm実装
   - same-box preference機能

2. calls.rs から重複ロジック削除(65行→14行)
   - 関数名解決処理を call_resolution::resolve_function_name() に置き換え
   - 51行削減(65-14)
   - 実質的には49行削減(モジュール宣言2行追加を考慮)

3. handlers/mod.rs にモジュール宣言追加
   - mod call_resolution; 宣言

【技術的改善】
- Single Source of Truth確立
  - 関数名解決アルゴリズムが1箇所に集約
  - 将来の修正・拡張が容易に

- 解決戦略の明確化
  1. Fast path: exact match
  2. Normalize with arity: "base/N"
  3. Unique-tail matching: ".method/N"
  4. Same-box preference: 現在の関数のbox優先
  5. Deterministic fallback: ソート後の最初の候補

【テスト】
 ビルド成功(0 errors)
 userbox_static_call_vm: PASS
 userbox_method_arity_vm: PASS
 userbox_using_package_vm: PASS
 全6テストPASS(quick/userbox_*)

【累計削減】
3,775行(Phase 1-4+8)+ 49行(Phase 5)= 3,824行削減

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 13:59:12 +09:00
167d33ed9e 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警告)
2025-11-01 13:46:34 +09:00
9be50f0a0c refactor(vm): Phase 4 - Void Guard統一化(重複削減)
boxes_void_guards.rs新規作成で28行の重複を排除

実装内容:
- handle_void_method()ヘルパー関数作成
- 7種類のメソッド(is_eof/length/substring/push/get_position/get_line/get_column)統一
- boxes.rs: 30行→18行(12行削減)
- 重複ブロック2箇所→シングルソース化

効果:
- 保守性向上: 単一の真実の源(Single Source of Truth)
- 可読性向上: 大きなmatchブロック→簡潔なヘルパー呼び出し
- バグ修正容易化: 1箇所修正で全体に反映

テスト: Void.is_eof(), Void.length()正常動作確認
2025-11-01 13:41:43 +09:00
367066376a refactor(handlers): extract boxes_plugin module (Phase 2-3) - Phase 2 complete!
Split handlers/boxes.rs (497→322 lines, -175 lines, -35.2%)

Changes:
- Created boxes_plugin.rs (175 lines)
  - Extracted invoke_plugin_box function
  - Handles PluginBoxV2 method dispatch
  - Includes fallback handlers for InstanceBox methods
  - Special handling for ConsoleBox.readLine, VoidBox methods
- Updated mod.rs to declare new module
- Updated boxes.rs to redirect to new module
- Build verified: 0 errors, 85 warnings

Phase 2 Complete Summary:
- boxes.rs: 1008→322 lines (-686 lines, -68.1% reduction!)
- Split into 3 focused modules:
  - boxes_object_fields.rs (359 lines) - getField/setField
  - boxes_instance.rs (150 lines) - InstanceBox dispatch
  - boxes_plugin.rs (175 lines) - Plugin dispatch

Overall Progress:
- Phase 1: Legacy deletion (2,997 lines)
- Phase 2-1: boxes_object_fields split (360 lines)
- Phase 2-2: boxes_instance split (151 lines)
- Phase 2-3: boxes_plugin split (175 lines)
- Total reduction: 3,683 lines deleted

Next: Phase 3 (builder_calls.rs split, ~142 lines)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 12:42:52 +09:00
232547baa3 refactor(handlers): extract boxes_instance module (Phase 2-2)
Split handlers/boxes.rs (648→497 lines, -151 lines, -23.3%)

Changes:
- Created boxes_instance.rs (150 lines)
  - Extracted try_handle_instance_box function
  - Handles InstanceBox method dispatch
  - Supports Class.method/arity and ClassInstance.method/arity
- Updated mod.rs to declare new module
- Updated boxes.rs to redirect to new module
- Build verified: 0 errors, 85 warnings

Progress:
- Phase 1: Legacy deletion (2,997 lines)
- Phase 2-1: boxes_object_fields split (360 lines)
- Phase 2-2: boxes_instance split (151 lines)
- Total reduction so far: 3,508 lines

Next: Phase 2-3 (boxes_plugin.rs, ~176 lines)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 12:38:48 +09:00
c8856e1a08 refactor(handlers): extract boxes_object_fields module (Phase 2-1)
Split handlers/boxes.rs (1008→648 lines, -360 lines, -35.7%)

Changes:
- Created boxes_object_fields.rs (359 lines)
  - Extracted try_handle_object_fields function
  - Handles getField/setField for InstanceBox
- Updated mod.rs to declare new module
- Updated boxes.rs to redirect to new module
- Build verified: 0 errors, 85 warnings

Progress:
- Phase 1: Legacy deletion (2,997 lines)
- Phase 2-1: boxes_object_fields split (360 lines)
- Total reduction so far: 3,357 lines

Next: Phase 2-2 (boxes_instance.rs), Phase 2-3 (boxes_plugin.rs)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 12:32:38 +09:00
cdf826cbe7 public: publish selfhost snapshot to public repo (SSOT using + AST merge + JSON VM fixes)
- SSOT using profiles (aliases/packages via nyash.toml), AST prelude merge
- Parser/member guards; Builder pin/PHI and instance→function rewrite (dev on)
- VM refactors (handlers split) and JSON roundtrip/nested stabilization
- CURRENT_TASK.md updated with scope and acceptance criteria

Notes: dev-only guards remain togglable via env; no default behavior changes for prod.
2025-09-26 14:34:42 +09:00
824ca600ea refactor: 大規模ファイル分割とプラグインリファクタリング
## 🎯 プラグイン整理
-  **nyash-json-plugin**: プロバイダー抽象化、NodeRep統一
-  **nyash-string-plugin**: TLVヘルパー整理
-  **nyash-net-plugin**: HTTPヘルパー分離、ソケット管理改善
-  **nyash-counter-plugin/fixture-plugin**: 基本構造整理

## 📂 mir_interpreter分割
-  **mir_interpreter.rs → mir_interpreter/ディレクトリ**
  - mod.rs: メイン構造体定義
  - execution.rs: 実行エンジン
  - memory.rs: メモリ管理
  - instructions/: 命令別実装

## 🔧 その他の改善
- テストファイル群の最適化
- LLVMコンパイラのメイン関数整理
- 不要なインポート削除

1000行超のファイルを適切なモジュール構造に分割完了!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 01:09:48 +09:00