8488df58a8
Phase 6 WIP: Type conversion helpers (11 sites, 23 lines)
...
Added conversion_helpers.rs with unified type conversion:
- load_as_box() for reg_load().to_nyash_box()
- load_as_string() for reg_load().to_string()
- load_as_int/bool() for type-checked loads
- load_args_as_boxes/values() for bulk conversion
Files updated (partial):
- boxes.rs: 2 sites (-6 lines)
- calls.rs: 5 sites (-10 lines)
- boxes_plugin.rs: 1 site (-3 lines)
- externals.rs: 3 sites (-4 lines)
Next: boxes_array, boxes_map, boxes_object_fields, boxes_instance
Tests: Phase 21.0 PASS (2/2, 100%)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-07 00:21:42 +09:00
2429627d04
Phase 5: Complete destination pattern unification (28 sites, 53 lines)
...
Unified remaining destination write patterns with new helpers:
- write_string() for VMValue::String writes
- write_from_box() for VMValue::from_nyash_box() patterns
Files updated:
- boxes.rs: 8 sites unified (-14 lines)
- boxes_plugin.rs: 9 sites unified (-17 lines)
- boxes_object_fields.rs: 7 sites unified (-14 lines)
- boxes_instance.rs: 2 sites unified (-4 lines)
- calls.rs: 2 sites unified (-4 lines)
- destination_helpers.rs: +28 lines (new helpers)
Impact: 28 sites unified, net -25 lines, improved maintainability
Tests: Phase 21.0 PASS (2/2, 100%)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-07 00:13:12 +09:00
22b668927e
refactor: complete error message unification (Phase 3.5)
...
Migrate remaining 45 error generation patterns to unified helpers:
- calls.rs: 13 sites → 0
- extern_provider.rs: 9 sites → 0
- externals.rs: 5 sites → 0
- boxes_plugin.rs: 5 sites → 0
- boxes.rs: 5 sites → 0
- boxes_string.rs: 4 sites → 0
- boxes_instance.rs: 2 sites → 0
- mod.rs + boxes_array.rs: 2 sites → 0
Error patterns now 100% unified:
- All 80 InvalidInstruction sites use helpers (100%)
- Consistent error formatting across entire codebase
- Single source of truth for error messages
Code reduction:
- Phase 3.5: 50-70 lines saved
- Cumulative (Phase 1+2+3+3.5): 200-267 lines removed (6-8% handlers)
- Total patterns unified: 192 (destination 60 + args 52 + errors 80)
Benefits:
- 100% error message consistency achieved
- Easy to modify error formats globally
- Foundation for i18n support ready
- Improved maintainability and testability
Test results: ✓ Build successful, Phase 21.0 smoke tests passing
Related: Phase 21.0 refactoring milestone complete
Risk: Low (error messages only, behavior preserved)
2025-11-06 23:34:46 +09:00
8d179e9499
refactor: add MIR interpreter utility helpers (Phase 1)
...
- Add destination write helpers (write_box_result, write_void, write_result)
- Add argument validation helpers (validate_args_exact/range/min)
- Add receiver conversion helper (convert_to_box)
- Update handlers to use new helpers
Reduces code duplication:
- Destination patterns: 37 call sites converted
- Each replacement saves 2-3 lines (74-111 lines saved)
- Helper infrastructure: 178 lines added
- Net improvement: Reduced duplication + better maintainability
Impact:
- Build: ✓ SUCCESS (0 errors, 146 warnings)
- Tests: ✓ 8/9 smoke tests PASS
- Functionality: ✓ PRESERVED (no behavior changes)
Files created:
- src/backend/mir_interpreter/utils/mod.rs
- src/backend/mir_interpreter/utils/destination_helpers.rs
- src/backend/mir_interpreter/utils/arg_validation.rs
- src/backend/mir_interpreter/utils/receiver_helpers.rs
Files modified: 15 handler files
- arithmetic.rs, boxes.rs, boxes_array.rs, boxes_instance.rs
- boxes_map.rs, boxes_object_fields.rs, boxes_plugin.rs
- boxes_string.rs, calls.rs, extern_provider.rs, externals.rs
- memory.rs, misc.rs, mod.rs
Related: Phase 21.0 refactoring
Risk: Low (pure refactoring, no behavior change)
2025-11-06 22:50:46 +09:00
47bd2d2ee2
Gate‑C(Core) OOB strict fail‑fast; String VM handler normalization; JSON lint Stage‑B root fixes via scanner field boxing and BinOp operand slotify; docs + smokes update
2025-11-01 18:45:26 +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
34be7d2d79
vm/router: minimal special-method extension (equals/1); toString mapping kept
...
mir: add TypeCertainty to Callee::Method (diagnostic only); plumb through builder/JSON/printer; backends ignore behaviorally
using: confirm unified prelude resolver entry for all runner modes
docs: update Callee architecture with certainty; update call-instructions; CURRENT_TASK note
tests: quick 40/40 PASS; integration (LLVM) 17/17 PASS
2025-09-28 01:33:58 +09:00
8ea95c9d76
docs: add instance-dispatch & birth invariants; smokes probe policy; archive CURRENT_TASK and replace with concise plan; impl VM stringify(Void) safety; tighten heavy probes; enable rewrite default ON
2025-09-27 08:56:43 +09:00
cb236b7f5a
json(vm): fix birth dispatch; unify constructor naming (Box.birth/N); JsonNode factories return JsonNodeInstance; quick: enable heavy JSON with probe; builder: NYASH_BUILDER_DEBUG_LIMIT guard; json_query_min(core) harness; docs/tasks updated
2025-09-27 08:45:25 +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
cf4b615afb
mir/vm: SSA pin+PHI + short-circuit; user-defined method calls → functions; entry single-pred PHIs; compare-operand pin; VM BoxCall fallback to InstanceBox methods; docs: update CURRENT_TASK (plan + acceptance)
...
- Lower And/Or to branch+PHI (RHS not evaluated)
- Always slotify compare operands (dominance safety)
- Insert single-predecessor PHIs at then/else/short-circuit entries
- pin_to_slot now logs (NYASH_PIN_TRACE) and participates in PHI
- Rewrite user-defined instance method calls to Box.method/Arity (builder)
- VM fallback: BoxCall on InstanceBox dispatches to lowered functions with 'me'+args
- Keep plugin/BoxCall path for core boxes (String/Array/Map)
- Add env-gated pre-pin for if/loop (NYASH_MIR_PREPIN)
- CURRENT_TASK: add SSA/userbox plan, debug steps, acceptance criteria
2025-09-26 05:28:20 +09:00
fd56b8049a
mir: implement proper short-circuit lowering (&&/||) via branch+phi; vm: add NYASH_VM_TRACE exec/phi logs and reg_load diagnostics; vm-fallback: minimal Void guards (push/get_position/line/column), MapBox.birth no-op; smokes: filter builtin Array/Map plugin notices; docs: CURRENT_TASK updated
2025-09-26 03:30:59 +09:00
85084664c2
docs+runner+parser: SSOT+AST using finalized (legacy text inlining removed); provider verify reads nyash.toml; preflight warn hook; method-body guard removed; CURRENT_TASK updated for next JSON work
2025-09-26 00:27:02 +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