5bc0fa861f
feat(joinir): Phase 188 Pattern 1 Core Implementation + Phase 189 Planning
...
Phase 188 Status: Planning & Foundation Complete (100%)
Completed Tasks:
✅ Task 188-1: Error Inventory (5 patterns identified)
✅ Task 188-2: Pattern Classification (3 patterns selected)
✅ Task 188-3: Design (51KB comprehensive blueprint)
✅ Task 188-4: Implementation Foundation (1,802 lines scaffolding)
✅ Task 188-5: Verification & Documentation
✅ Pattern 1 Core Implementation: Detection + Lowering + Routing
Pattern 1 Implementation (322 lines):
- Pattern Detection: is_simple_while_pattern() in loop_pattern_detection.rs
- JoinIR Lowering: lower_simple_while_to_joinir() in simple_while_minimal.rs (219 lines)
- Generates 3 functions: entry, loop_step (tail-recursive), k_exit
- Implements condition negation: exit_cond = !(i < 3)
- Tail-recursive Call pattern with state propagation
- Routing: Added "main" to function routing list in control_flow.rs
- Build: ✅ SUCCESS (0 errors, 34 warnings)
Infrastructure Blocker Identified:
- merge_joinir_mir_blocks() only handles single-function JoinIR modules
- Pattern 1 generates 3 functions (entry + loop_step + k_exit)
- Current implementation only merges first function → loop body never executes
- Root cause: control_flow.rs line ~850 takes only .next() function
Phase 189 Planning Complete:
- Goal: Refactor merge_joinir_mir_blocks() for multi-function support
- Strategy: Sequential Merge (Option A) - merge all functions in call order
- Effort estimate: 5.5-7.5 hours
- Deliverables: README.md (16KB), current-analysis.md (15KB), QUICKSTART.md (5.8KB)
Files Modified/Created:
- src/mir/loop_pattern_detection.rs (+50 lines) - Pattern detection
- src/mir/join_ir/lowering/simple_while_minimal.rs (+219 lines) - Lowering
- src/mir/join_ir/lowering/loop_patterns.rs (+803 lines) - Foundation skeleton
- src/mir/join_ir/lowering/mod.rs (+2 lines) - Module registration
- src/mir/builder/control_flow.rs (+1 line) - Routing fix
- src/mir/builder/loop_frontend_binding.rs (+20 lines) - Binding updates
- tools/test_phase188_foundation.sh (executable) - Foundation verification
- CURRENT_TASK.md (updated) - Phase 188/189 status
Next: Phase 189 implementation (merge_joinir_mir_blocks refactor)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-05 07:47:22 +09:00
fa8a96a51b
docs(joinir): Phase 187 LoopBuilder Physical Removal - Completion Documentation
...
## Changes
- Added Phase 187 section to Phase 180 README documenting complete LoopBuilder deletion
- Documented all 4 tasks completion (187-1 through 187-4)
- Added architectural impact analysis before/after Phase 187
- Documented code deletion summary and archival strategy
- Explained NYASH_LEGACY_LOOPBUILDER variable status after deletion
## Key Achievements
- LoopBuilder module (8 files, ~1000+ lines) completely deleted
- IfInLoopPhiEmitter preserved in minimal new module
- JoinIR Frontend is now sole authoritative loop lowering system
- Explicit failures replace implicit fallbacks
## Architectural Impact
- Single authoritative path (JoinIR Frontend)
- No implicit fallbacks
- Future JoinIR expansion is only way forward
- Fail-Fast principle enforced at architecture level
## Related Phases
- Phase 185: Strict mode semantics unified
- Phase 186: Hard freeze with access control guard
- Phase 187: Physical module deletion (this change)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 23:51:49 +09:00
000335c32e
feat(hako_check): Phase 154 MIR CFG integration & HC020 dead block detection
...
Implements block-level unreachable code detection using MIR CFG information.
Complements Phase 153's method-level HC019 with fine-grained analysis.
Core Infrastructure (Complete):
- CFG Extractor: Extract block reachability from MirModule
- DeadBlockAnalyzerBox: HC020 rule for unreachable blocks
- CLI Integration: --dead-blocks flag and rule execution
- Test Cases: 4 comprehensive patterns (early return, constant false, infinite loop, break)
- Smoke Test: Validation script for all test cases
Implementation Details:
- src/mir/cfg_extractor.rs: New module for CFG→JSON extraction
- tools/hako_check/rules/rule_dead_blocks.hako: HC020 analyzer box
- tools/hako_check/cli.hako: Added --dead-blocks flag and HC020 integration
- apps/tests/hako_check/test_dead_blocks_*.hako: 4 test cases
Architecture:
- Follows Phase 153 boxed modular pattern (DeadCodeAnalyzerBox)
- Optional CFG field in Analysis IR (backward compatible)
- Uses MIR's built-in reachability computation
- Gracefully skips if CFG unavailable
Known Limitation:
- CFG data bridge pending (Phase 155): analysis_consumer.hako needs MIR access
- Current: DeadBlockAnalyzerBox implemented, but CFG not yet in Analysis IR
- Estimated 2-3 hours to complete bridge in Phase 155
Test Coverage:
- Unit tests: cfg_extractor (simple CFG, unreachable blocks)
- Integration tests: 4 test cases ready (will activate with bridge)
- Smoke test: tools/hako_check_deadblocks_smoke.sh
Documentation:
- phase154_mir_cfg_inventory.md: CFG structure investigation
- phase154_implementation_summary.md: Complete implementation guide
- hako_check_design.md: HC020 rule documentation
Next Phase 155:
- Implement CFG data bridge (extract_mir_cfg builtin)
- Update analysis_consumer.hako to call bridge
- Activate HC020 end-to-end testing
🤖 Generated with Claude Code (https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 15:00:45 +09:00
447bbec998
refactor(joinir): Split ast_lowerer and join_ir_vm_bridge into modules
...
ast_lowerer.rs → ast_lowerer/ (10 files):
- mod.rs: public surface + entry dispatch
- context.rs: ExtractCtx helpers
- expr.rs: expression-to-JoinIR extraction
- if_return.rs: simple if→Select lowering
- loop_patterns.rs: loop variants (simple/break/continue)
- read_quoted.rs: read_quoted_from lowering (Phase 45-46)
- nested_if.rs: NestedIfMerge lowering
- analysis.rs: loop if-var analysis + metadata helpers
- tests.rs: frontend lowering tests
- README.md: module documentation
join_ir_vm_bridge.rs → join_ir_vm_bridge/ (5 files):
- mod.rs: public surface + shared helpers
- convert.rs: JoinIR→MIR lowering
- runner.rs: VM execution entry (run_joinir_via_vm)
- meta.rs: experimental metadata-aware hooks
- tests.rs: bridge-specific unit tests
- README.md: module documentation
Benefits:
- Clear separation of concerns per pattern
- Easier navigation and maintenance
- Each file has single responsibility
- README documents module boundaries
Co-authored-by: ChatGPT <noreply@openai.com >
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-28 17:42:19 +09:00
51ff558904
feat(phase32): L-2.1 Stage-1 UsingResolver JoinIR integration + cleanup
...
Phase 32 L-2.1 complete implementation:
1. Stage-1 UsingResolver main line JoinIR connection
- CFG-based LoopForm construction for resolve_for_source/5
- LoopToJoinLowerer integration with handwritten fallback
- JSON snapshot tests 6/6 PASS
2. JoinIR/VM Bridge improvements
- Simplified join_ir_vm_bridge.rs dispatch logic
- Enhanced json.rs serialization
- PHI core boxes cleanup (local_scope_inspector, loop_exit_liveness, loop_var_classifier)
3. Stage-1 CLI enhancements
- Extended args.rs, groups.rs, mod.rs for new options
- Improved stage1_bridge module (args, env, mod)
- Updated stage1_cli.hako
4. MIR builder cleanup
- Simplified if_form.rs control flow
- Removed dead code from loop_builder.rs
- Enhanced phi_merge.rs
5. Runner module updates
- json_v0_bridge/lowering.rs improvements
- dispatch.rs, selfhost.rs, modes/vm.rs cleanup
6. Documentation updates
- CURRENT_TASK.md, AGENTS.md
- Various docs/ updates
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-26 10:17:37 +09:00
da1a5558e5
Normalize passes keep spans and clean warnings
2025-11-24 15:02:51 +09:00
466e636af6
Span trace utilities and runner source hint
2025-11-24 14:17:02 +09:00
7a9b23c9d1
feat(joinir): Phase 27-shortterm S-4.1~S-4.3 - JoinIR→VM Bridge基本実装
...
## S-4.1: VM インターフェース調査
- VMValue 型定義確認 (Integer, Bool, String, Void, BoxRef)
- VM API 確認 (execute_module, stats_counters)
- Task tool による詳細レポート取得
## S-4.2: JoinValue ↔ VMValue 変換関数実装
**新規追加**: src/mir/join_ir_ops.rs (+121行)
- JoinValue::to_vm_value() - 4型すべて対応
- JoinValue::from_vm_value() - エラーハンドリング付き
- Float/Future/BoxRef は非対応(エラー返却)
- 包括的テスト追加 (正常系・異常系)
## S-4.3: join_ir_vm_bridge.rs 基本構造実装
**新規ファイル**: src/mir/join_ir_vm_bridge.rs (350行)
### Public API
- run_joinir_via_vm() - JoinIR モジュールを VM で実行
### JoinIR → MIR 変換
- convert_joinir_to_mir() - JoinModule → MirModule
- convert_join_function_to_mir() - JoinFunction → MirFunction
- convert_mir_like_inst() - Compute命令変換
### 最小実装スコープ (Phase 27-shortterm)
✅ Compute 命令 (Const, BinOp, Compare, BoxCall)
✅ Ret 命令
⏳ Call/Jump 命令 (TODO: S-4.4 で実装)
### 設計方針
- JoinIR の正規化構造 (Pinned/Carrier, Exit φ) を保持
- マッピングだけで済ませる(正規化は消えない)
- VM の機能 (GC, plugins, error handling) を活用
## コンパイル
✅ 完全成功 (0エラー)
## 次のステップ
S-4.4: skip_ws で A/B テスト green 化
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-24 06:16:45 +09:00
78c9d4d7fc
feat(joinir): Phase 27.8-1~3 — Ops Box導入 + Toggle対応完了
...
## Phase 27.8-1: JoinIR 命令意味箱(Ops Box)作成 ✅
**新規ファイル**: `src/mir/join_ir_ops.rs`
- `eval_binop()`: Add, Sub, Mul, Div, Or, And の評価ロジック一元化
- `eval_compare()`: Lt, Le, Gt, Ge, Eq, Ne の比較ロジック一元化
- エラー処理: `JoinIrOpError` 型で型安全
- 完全テストカバレッジ: 13個のユニットテスト
**効果**:
- BinOp/Compare の評価ロジックを一箇所に集約
- 再利用可能な API で将来の拡張が容易
- テスタビリティ向上
## Phase 27.8-2: join_ir_runner.rs の Ops Box 統合 ✅
**変更**: `src/mir/join_ir_runner.rs`
- BinOp/Compare の実装を ops box に完全移譲(約70行削減)
- `JoinValue` / `JoinIrOpError` を ops box から再エクスポート
- 後方互換性維持: `JoinRuntimeError = JoinIrOpError`
**効果**:
- コード重複削減(約70行)
- 実装の一貫性保証(ops box の単一実装を使用)
## Phase 27.8-3: MIR→JoinIR Toggle 対応 ✅
**変更**: `src/mir/join_ir.rs`
- `lower_skip_ws_to_joinir()`: トグル対応ディスパッチャー
- `lower_skip_ws_handwritten()`: 既存実装をリネーム(Phase 27.1-27.7)
- `lower_skip_ws_from_mir()`: MIR自動解析版スタブ(Phase 27.8-4 で実装予定)
**環境変数制御**:
```bash
# 手書き版(デフォルト)
./target/release/hakorune program.hako
# MIR自動解析版(Phase 27.8-4 実装予定)
NYASH_JOINIR_LOWER_FROM_MIR=1 ./target/release/hakorune program.hako
```
**効果**:
- 段階的な移行が可能(既存動作を完全に維持)
- A/B テストによる検証が容易
## 変更ファイル
- `src/mir/join_ir_ops.rs` (新規): Ops Box 実装
- `src/mir/join_ir_runner.rs`: Ops Box 使用に変更
- `src/mir/join_ir.rs`: Toggle 対応ディスパッチャー追加
- `src/mir/mod.rs`: join_ir_ops モジュール追加
## コンパイル結果
✅ 0 errors, 18 warnings(既存警告のみ)
✅ ビルド成功
## 次のステップ
**Phase 27.8-4**: `lower_skip_ws_from_mir()` 本実装
- MirQuery を使った MIR 解析
- パターンマッチング(init, header, break checks, body)
- JoinIR 自動生成(entry function + loop_step function)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-23 14:47:00 +09:00
0852a397d9
Add experimental JoinIR runner and tests
2025-11-23 08:38:15 +09:00
2692eafbbf
feat(mir): Phase 26-H JoinIR型定義実装完了 - ChatGPT設計
...
## 実装内容(Step 1-3 完全達成)
### Step 1: src/mir/join_ir.rs 型定義追加
- **JoinFuncId / JoinContId**: 関数・継続ID型
- **JoinFunction**: 関数(引数 = φノード)
- **JoinInst**: Call/Jump/Ret/Compute 最小命令セット
- **MirLikeInst**: 算術・比較命令ラッパー
- **JoinModule**: 複数関数保持コンテナ
- **単体テスト**: 型サニティチェック追加
### Step 2: テストケース追加
- **apps/tests/joinir_min_loop.hako**: 最小ループ+breakカナリア
- **src/tests/mir_joinir_min.rs**: 手書きJoinIR構築テスト
- MIR → JoinIR手動構築で型妥当性確認
- #[ignore] で手動実行専用化
- NYASH_JOINIR_EXPERIMENT=1 トグル制御
### Step 3: 環境変数トグル実装
- **NYASH_JOINIR_EXPERIMENT=1**: 実験モード有効化
- **デフォルト挙動**: 既存MIR/LoopForm経路のみ(破壊的変更なし)
- **トグルON時**: JoinIR手書き構築テスト実行
## Phase 26-H スコープ遵守
✅ 型定義のみ(変換ロジックは未実装)
✅ 最小限の命令セット
✅ Debug 出力で妥当性確認
✅ 既存パイプライン無影響
## テスト結果
```
$ NYASH_JOINIR_EXPERIMENT=1 cargo test --release mir_joinir_min_manual_construction -- --ignored --nocapture
[joinir/min] MIR module compiled, 3 functions
[joinir/min] JoinIR module constructed:
[joinir/min] ✅ JoinIR型定義は妥当(Phase 26-H)
test result: ok. 1 passed; 0 failed
```
## JoinIR理論の実証
- **φノード = 関数引数**: `fn loop_step(i, k_exit)`
- **merge = join関数**: 分岐後の合流点
- **ループ = 再帰関数**: `loop_step` 自己呼び出し
- **break = 継続呼び出し**: `k_exit(i)`
## 次フェーズ (Phase 27.x)
- LoopForm v2 → JoinIR 自動変換実装
- break/continue ハンドリング
- Exit PHI の JoinIR 引数化
🌟 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
Co-Authored-By: ChatGPT <noreply@openai.com >
2025-11-23 04:10:12 +09:00
28a312ea0d
feat(naming): Phase 25.4-A - NamingBox SSOT化完了
...
🎯 目的: static/global 呼び出しの名前決定を src/mir/naming.rs に一本化
✅ 実装完了:
- NamingBox(src/mir/naming.rs)実装
- encode_static_method(box, method, arity)
- normalize_static_global_name(func_name)
- static/global 名前の正規化ロジック統一
- MIR Builder統合(SSOT使用)
- src/mir/builder/decls.rs: build_static_main_box
- src/mir/builder/exprs.rs: 静的メソッド呼び出し
- src/mir/builder/metadata/propagate.rs: メタデータ伝播
- src/mir/builder/observe/mod.rs: Observe機能
- src/mir/builder/observe/types.rs: 型観測(新規)
- VM実行器統合(SSOT使用)
- src/backend/mir_interpreter/handlers/calls/global.rs
- normalize_static_global_name使用
- レガシーフォールバック削除済み確認
- テスト追加
- src/tests/mir_static_box_naming.rs
- encode/normalize の動作検証
📚 ドキュメント:
- docs/development/architecture/mir-naming-box.md
- NamingBoxの設計思想
- SSOT原則の説明
- 使用例
🎯 効果:
- 名前決定ロジックが1箇所に集約
- Builder/VM で同じ正規化ルールを使用
- 将来の名前空間拡張が容易
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-21 09:01:43 +09:00
f9d100ce01
chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
...
Phase 25.1 完了成果:
- ✅ LoopForm v2 テスト・ドキュメント・コメント完備
- 4ケース(A/B/C/D)完全テストカバレッジ
- 最小再現ケース作成(SSAバグ調査用)
- SSOT文書作成(loopform_ssot.md)
- 全ソースに [LoopForm] コメントタグ追加
- ✅ Stage-1 CLI デバッグ環境構築
- stage1_cli.hako 実装
- stage1_bridge.rs ブリッジ実装
- デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
- アーキテクチャ改善提案文書
- ✅ 環境変数削減計画策定
- 25変数の完全調査・分類
- 6段階削減ロードマップ(25→5、80%削減)
- 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)
Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更
🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化
Co-Authored-By: Claude <noreply@anthropic.com >
Co-Authored-By: ChatGPT <noreply@openai.com >
Co-Authored-By: Task Assistant <task@anthropic.com >
2025-11-21 06:25:17 +09:00
bc06fc61df
feat(mir): Phase 26-A-1 ValueId型安全化 - MirValueKind導入
...
## 🎯 目的
GUARDバグのような「ValueIdの意味的曖昧性」から生じるバグを根絶
## ✅ 実装内容
- **新規**: `src/mir/value_kind.rs` (442行)
- `MirValueKind` 列挙型(6種類の型分類)
- Parameter(u32): 関数パラメータ
- Local(u32): ローカル変数
- Constant: 定数値
- Temporary: 一時値
- Pinned: ブロック跨ぎ変数
- LoopCarrier: ループ内再定義変数
- `TypedValueId` 構造体(型安全ラッパー)
- ValueId + MirValueKind のペア
- is_parameter(), is_local() 等の型安全判定メソッド
## ✅ テスト結果
- **全12テストPASS** (0.00s)
- ✅ test_guard_check_bug_prevention: GUARDバグ再現防止
- ✅ test_parameter_detection: ValueId(0)でもParameter判定可能
- ✅ test_loop_carrier_detection: LoopCarrier型検出
- ✅ その他9テスト全PASS
## 📊 効果
- **型安全性**: ValueId(0)がParameterかLocalか判定可能
- **バグ予防**: 同種のバグ80%削減見込み
- **自己文書化**: 型情報で意味が明確
- **後方互換性**: From<TypedValueId> for ValueId実装
## 📋 次のステップ
- Phase 26-A-2: MirBuilder統合(value_kindsフィールド追加)
- Phase 26-A-3: パラメータ登録修正
- Phase 26-A-4: loop_builder.rs修正(is_parameter根本治療)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-20 09:29:23 +09:00
9bdf2ff069
chore: Phase 25.2関連ドキュメント更新&レガシーテストアーカイブ整理
...
## ドキュメント更新
- CURRENT_TASK.md: Phase 25.2完了記録
- phase-25.1b/e/q/25.2 README更新
- json_v0_bridge/README.md新規追加
## テストファイル整理
- vtable_*テストをtests/archive/に移動(6ファイル)
- json_program_loop.rsテスト追加
## コード整理
- プラグイン(egui/python-compiler)微修正
- benchmarks.rs, instance_v2.rs更新
- MIR関連ファイル微調整
## 全体成果
Phase 25.2完了により:
- LoopSnapshotMergeBox統一管理実装
- ValueId(1283)バグ根本解決
- ~35行コード削減(目標210行の16%)
- 11テスト全部PASS、3実行テストケースPASS
2025-11-20 03:56:12 +09:00
39f5256c18
📊 Phase 25.1l: Region観測レイヤー骨格 + スコープ契約設計理解
...
**Region Box統一理論の実装開始**
新規追加:
- src/mir/region/mod.rs: Region/RefSlotKind型定義
- src/mir/region/observer.rs: Region観測レイヤー
- docs/development/roadmap/phases/phase-25.1l/: 設計ドキュメント
主要概念:
- Region Box = Function/Loop/If の統一箱
- RefSlotKind = GC管理用スロット種別(Strong/Weak/Borrowed/NonRef)
- 観測専用(NYASH_REGION_TRACE=1で動作、挙動変更なし)
設計理解の深化:
- ValueId(40)問題 = LoopForm v2スコープ契約違反の症状
- 根本解決 = Region観測で無名一時値のスコープまたぎを検出
- 箱理論3原則: 境界明確化/差し替え可能/段階的移行
関連議論:
- ChatGPT提案: Region統一理論でGC/寿命管理の基盤構築
- SlotRegistry: 変数の単一真実源(SSOT)
- 階層構造: FunctionRegion → LoopRegion → IfRegion
次のステップ:
- Phase 1: Region観測(現在)- 非破壊的追加
- Phase 2: メタデータ出力(MIR JSON拡張)
- Phase 3: GC統合(retain/release挿入)
テスト追加:
- lang/src/compiler/tests/stageb_mini_driver.hako
- tools/test_loopssa_breakfinder_slot.sh
Build: ✅ 全警告は既存のもの
Tests: 既存テスト全て緑維持
2025-11-19 02:44:40 +09:00
d3cbc71c9b
feat(mir): Phase 25.1f完了 - Conservative PHI + ControlForm観測レイヤー
...
🎉 Conservative PHI Box理論による完全SSA構築
**Phase 7-B: Conservative PHI実装**
- 片方branchのみ定義変数に対応(emit_void使用)
- 全変数にPHI生成(Conservative Box理論)
- Stage-1 resolver全テスト緑化(3/3 PASS)
**Phase 25.1f: ControlForm観測レイヤー**
- LoopShape/IfShape/ControlForm構造定義
- Loop/If統一インターフェース実装
- debug_dump/debug_validate機能追加
- NYASH_CONTROL_FORM_TRACE環境変数対応
**主な変更**:
- src/mir/builder/phi.rs: Conservative PHI実装
- src/mir/control_form.rs: ControlForm構造(NEW)
- src/mir/loop_builder.rs: LoopForm v2デフォルト化
**テスト結果**:
✅ mir_stage1_using_resolver_min_fragment_verifies
✅ mir_stage1_using_resolver_full_collect_entries_verifies
✅ mir_parserbox_parse_program2_harness_parses_minimal_source
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
Co-Authored-By: ChatGPT <chatgpt@openai.com >
2025-11-18 18:56:35 +09:00
86489ffe43
Phase 21.3 WIP: Hako Source Checker improvements
...
## 🎯 Checker/Analyzer拡張
### ✅ 実装追加
- テストフレームワーク追加(tools/hako_check/tests/)
- ルール改善(HC003グローバルassign、HC040静的箱トップレベルassign)
- テストランナー(run_tests.sh)
### 🔧 Rust側修正
- AST utilities拡張(src/ast/utils.rs)
- MIR lowerers新設(src/mir/lowerers/)
- Parser制御フロー改善(src/parser/statements/control_flow.rs)
- Tokenizer識別子処理改善(src/tokenizer/lex_ident.rs)
### 📁 主要変更
- tools/hako_check/cli.hako - CLI改善
- tools/hako_check/hako_source_checker.hako - Checker core更新
- tools/hako_check/tests/ - NEW (テストケース追加)
- tools/hako_check/run_tests.sh - NEW (テストランナー)
- src/mir/lowerers/ - NEW (MIR lowering utilities)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-07 21:04:01 +09:00
44a5158a14
hv1: early-exit at main (no plugin init); tokenizer: Stage-3 single-quote + full escapes (\/ \b \f \' \r fix); builder: route BinOp via SSOT emit_binop_to_dst; hv1 verify canary route (builder→Core); docs: phase-20.39 updates
2025-11-04 20:46:43 +09:00
dd65cf7e4c
builder+vm: unify method calls via emit_unified_call; add RouterPolicy trace; finalize LocalSSA/BlockSchedule guards; docs + selfhost quickstart
...
- Unify standard method calls to emit_unified_call; route via RouterPolicy and apply rewrite::{special,known} at a single entry.\n- Stabilize emit-time invariants: LocalSSA finalize + BlockSchedule PHI→Copy→Call ordering; metadata propagation on copies.\n- Known rewrite default ON (userbox only, strict guards) with opt-out flag NYASH_REWRITE_KNOWN_DEFAULT=0.\n- Expand TypeAnnotation whitelist (is_digit_char/is_hex_digit_char/is_alpha_char/Map.has).\n- Docs: unified-method-resolution design note; Quick Reference normalization note; selfhosting/quickstart.\n- Tools: add tools/selfhost_smoke.sh (dev-only).\n- Keep behavior unchanged for Unknown/core/user-instance via BoxCall fallback; all tests green (quick/integration).
2025-09-28 20:38:09 +09:00
9384c80623
using: safer seam defaults (fix_braces OFF by default) + path-alias handling; json_native: robust integer parse + EscapeUtils unquote; add JsonCompat layer; builder: preindex static methods + fallback for bare calls; diagnostics: seam dump + function-call trace
2025-09-25 10:23:14 +09:00
81211c22ad
feat: MIR Call命令統一Phase 3.1-3.2完了!統一Call実装進行中
...
✨ Phase 3.1-3.2実装完了
- build_indirect_call_expressionでCallTarget::Value使用
- print関数をcall_global print()として統一
- build_function_callでemit_unified_call使用
- ExternCall(env.console.log)→Callee::Global(print)完全移行
🏗️ MIR統一基盤構築
- src/mir/definitions/call_unified.rs: 統一定義(297行)
- emit_unified_call()と便利メソッド3種実装
- NYASH_MIR_UNIFIED_CALL=1で段階移行制御
- VM実行器でCallee対応実装済み
📊 進捗状況(26%削減見込み)
- Phase 1-2: ✅ 基盤構築完了
- Phase 3.1-3.2: ✅ 基本関数統一完了
- Phase 3.3: 🔄 BoxCall統一中
- Phase 4: 📅 Python LLVM(最優先・63%削減)
- Phase 5: 📅 PyVM/VM統一
📚 ドキュメント更新
- CLAUDE.md: テストスクリプト参考集追加
- CURRENT_TASK.md: Phase 3進捗更新
- python-llvm-priority-rationale.md: 優先順位戦略文書化
- mir-call-unification-master-plan.md: スケジュール最新化
🎯 6種類→1種類: Call/BoxCall/PluginInvoke/ExternCall/NewBox/NewClosure → MirCall統一へ
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-24 01:05:44 +09:00
2e93403de0
phase15: implement Phase S root treatment for break control flow
...
🔧 **Phase S (Immediate Stabilization) Implementation**
- Create control flow utilities module (src/mir/utils/)
- Refactor loop_builder.rs duplicated code to utilities
- Fix PHI incoming predecessor capture per ChatGPT Pro analysis
📊 **AI Collaborative Analysis Complete**
- Task agent: Root cause identification
- Gemini: Strategic 3-phase approach
- codex: Advanced type inference solution (archived)
- ChatGPT Pro: Definitive staged treatment strategy
🗂️ **Documentation & Archive**
- Strategy document: docs/development/strategies/break-control-flow-strategy.md
- codex solutions: archive/codex-solutions/ (100+ lines changes)
- Update CLAUDE.md with 2025-09-23 progress
⚡ **Expected Impact**
- Resolve collect_prints null return issue
- Eliminate code duplication (4 locations unified)
- Foundation for Phase M (PHI unification) and Phase L (BuildOutcome)
🎯 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-23 07:13:32 +09:00
da78fc174b
selfhost/runtime: Stage 0-1 runner + MIR JSON loader (summary) with trace; compiler: scopebox/loopform prepass wiring (flags, child args); libs: add P1 standard boxes (console/string/array/map) as thin wrappers; runner: pass --box-pref via env; ops_calls dispatcher skeleton; docs: selfhost executor roadmap + scopebox/loopform notes; smokes: selfhost runner + identity prepasses; CURRENT_TASK: update plan and box lib schedule
2025-09-22 21:52:39 +09:00
8e4cadd349
selfhost(pyvm): MiniVmPrints – prefer JSON route early-return (ok==1) to avoid fallback loops; keep default behavior unchanged elsewhere
2025-09-22 07:54:25 +09:00
486adfbec5
mir(hints): add no-op hint types and sink; expose module (scaffold, zero-cost)
2025-09-20 02:08:52 +09:00
d99b941218
docs: add MIR13 mode doc and set PHI-off as default; bridge lowering split (if/loop/try); llvmlite resolver stabilization; curated runner default PHI-off; refresh CURRENT_TASK.md
2025-09-17 10:58:12 +09:00
adbb0201a9
chore(fmt): add legacy stubs and strip trailing whitespace to unblock cargo fmt
2025-09-17 07:43:07 +09:00
9dc5c9afb9
refactor: split optimizer/verifier/parser modules (mainline); add runner trace/directives; add LLVM terminator/select scaffolds; extract AST Span; update CURRENT_TASK with remaining plan
2025-09-17 05:56:33 +09:00
06c77c1026
chore(mir): prune legacy instruction sets ( #129 )
2025-09-10 17:23:26 +09:00
864473336e
merge: resolve conflicts (prefer cranelift-dev for Core-13 defaults; drop modules/using, add env.local/env.box shims)
2025-09-08 01:28:39 +09:00
b8bdb867d8
Merge selfhosting-dev into main (Core-13 pure CI/tests + LLVM bridge) ( #126 )
...
* WIP: sync before merging origin/main
* fix: unify using/module + build CLI; add missing helper in runner; build passes; core smokes green; jit any.len string now returns 3
* Apply local changes after merging main; keep docs/phase-15 removed per main; add phase-15.1 docs and tests
* Remove legacy docs/phase-15/README.md to align with main
* integration: add Core-13 pure CI, tests, and minimal LLVM execute bridge (no docs) (#125 )
Co-authored-by: Tomoaki <tomoaki@example.com >
---------
Co-authored-by: Selfhosting Dev <selfhost@example.invalid >
Co-authored-by: Tomoaki <tomoaki@example.com >
2025-09-07 07:36:15 +09:00
d62114c705
Core-13 pure: add CI workflows, VM e2e tests, LLVM parity bridge (minimal); do not touch private docs
2025-09-07 07:28:53 +09:00
0ed3c6a919
refactor(mir): MIR builder.rsのサブモジュール分割完了 - ChatGPT5による自動リファクタリング成功
...
- builder.rsを12個の機能別モジュールに分割
- decls.rs: 宣言処理
- exprs*.rs: 式処理(call, lambda, peek, qmark, include)
- fields.rs: フィールドアクセス
- stmts.rs: 文処理
- utils.rs: 共通ユーティリティ
- セルフホスティング前の糖衣構文圧縮フェーズ開始
- CURRENT_TASK.md: Phase 12.7進捗更新
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-04 20:14:26 +09:00
fb2d8e37d5
🎉 Phase 11.8/12.7: MIR Core-13 完全実装 + 糖衣構文ドキュメント更新
...
主要な変更:
- MIR Core-13命令セット確定(Load/Store削除の革命的設計)
- Const, BinOp, Compare(値・計算)
- Jump, Branch, Return, Phi(制御)
- Call, BoxCall, ExternCall(呼び出し)
- TypeOp, Safepoint, Barrier(メタ)
- Phase 12.7糖衣構文ドキュメント整理(超圧縮重視、可逆変換保証)
- MIRビルダーのモジュール分割完了
- vtableテストスイート拡充
- AI協調開発ツール追加(並列リファクタリング支援)
詳細:
- src/mir/instruction_introspection.rs: core13_instruction_names()追加
- MIRビルダー分割: decls.rs, exprs_*.rs, fields.rs
- plugin_loader_v2: errors.rs, host_bridge.rs分離
- 論文用データ: mir13-final.md作成
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-04 11:34:15 +09:00
53d88157aa
Phase 12: 統一TypeBox ABI実装開始 - ChatGPT5による極小コアABI基盤構築
...
- TypeBox ABI雛形: メソッドスロット管理システム追加
- Type Registry: Array/Map/StringBoxの基本メソッド定義
- Host API: C ABI逆呼び出しシステム実装
- Phase 12ドキュメント整理: 設計文書統合・アーカイブ化
- MIR Builder: クリーンアップと分離実装完了
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-03 05:04:56 +09:00
de99b40bee
Phase 12 TypeBox統合ABI設計完了: C ABI + Nyash ABI革命的統合
...
主な成果:
- TypeBox(型情報をBoxとして扱う)による統合ABI設計
- C ABI + Nyash ABIの完全統合仕様書作成
- 3大AI専門家(Gemini/Codex/ChatGPT5)による検証済み
- ChatGPT5の10個の安全性改善提案を反映
- README.mdのドキュメント更新(全起点から到達可能)
MapBox拡張:
- string型キーサポート(従来のi64に加えて)
- remove/clear/getOr/keysStr/valuesStr/toJson実装
- keys()/values()のランタイムシムサポート(TypeBox待ち)
その他の改善:
- Phase 11.9(文法統一化)ドキュメント追加
- Phase 16(FoldLang)ドキュメント追加
- 非同期タイムアウトテスト追加
- 各種ビルド警告(未使用import等)は次のリファクタリングで対応予定
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-02 09:26:09 +09:00
1eee62a8ea
feat(jit): JIT Strictモード実装とプラグイン経路の安定化
...
- InvokePolicy/Observe導入でLowererの分岐をスリム化
- ArrayBox/MapBox/StringBoxのプラグイン経路統一
- 特殊コメント機能(@jit-debug, @plugin-builtins, @jit-strict)実装
- 型ヒント伝搬パス(TypeHintPass)を独立モジュール化
- VM→Plugin引数整合の安定化(I64統一、IntegerBox自動プリミティブ化)
- StringBoxのpost-birth初期化(空文字列セグフォルト修正)
- JIT観測サンプル追加(Array/Map/String)
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-29 21:39:47 +09:00
e21778c048
phase_9_79b_1: Add Unified Registry IDs + Builder Slotting\n- MIR BoxCall carries optional method_id (slot)\n- Slot registry with universal slots [0..3]\n- Builder resolves method_id when receiver type known\n- Printer shows method_id; backends updated\n- Update CURRENT_TASK + MIR spec note
2025-08-26 20:48:48 +09:00
22212aa314
refactor: Major interpreter modularization and P2PBox enhancements
...
Major Interpreter Refactoring:
- Split core.rs (373 lines removed) into focused modules
- Split expressions/calls.rs (460 lines removed) into cleaner structure
- Added new modules: calls.rs, errors.rs, eval.rs, methods_dispatch.rs, state.rs
- Improved separation of concerns across interpreter components
P2PBox Enhancements:
- Added on_once() for one-time event handlers
- Added off() for handler deregistration
- Implemented handler flags with AtomicBool for thread-safe management
- Added loopback testing cache (last_from, last_intent_name)
- Improved Arc-based state sharing for transport and handlers
Plugin Loader Unification (In Progress):
- Created plugin_loader_unified.rs skeleton
- Created plugin_ffi_common.rs for shared FFI utilities
- Migration plan documented (2400 lines → 1100 lines target)
MIR & VM Improvements:
- Enhanced modularized MIR builder structure
- Added BoxCall dispatch improvements
- Better separation in builder modules
Documentation Updates:
- Added Phase 9.79a unified box dispatch plan
- Created plugin loader migration plan
- Updated CURRENT_TASK.md with latest progress
All tests passing (180 tests) - ready for next phase of refactoring
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-26 19:13:57 +09:00
391a095f4c
Phase 9.78h: Stabilize MIR26 pipeline
...
- Add lib test to sync Core Instruction names with docs (INSTRUCTION_SET.md)
- Optimizer: Pass 0 normalizes legacy ops -> unified (TypeCheck/Cast->TypeOp,
WeakNew/WeakLoad->WeakRef, BarrierRead/Write->Barrier)
- Optimizer: diagnostics for legacy ops; forbid via NYASH_OPT_DIAG_FORBID_LEGACY=1
- Runner: treat diagnostics (unlowered/legacy) as fatal when enabled
- Printer: unify legacy print style to TypeOp/WeakRef/Barrier
- Verifier: treat Phi inputs correctly (skip merge/dominance violations for Phi)
- Docs: update PHI_NORMALIZATION_PLAN; CURRENT_TASK: add risk note for op duplication
- Misc: PHI debugging/logs kept stable; snapshots still green
2025-08-26 06:30:01 +09:00
bf4b87526e
phase(9.78h): stabilize MIR/VM pipeline
...
- Add MIR26 doc≡code sync test (tests/mir_instruction_set_sync.rs)
- Quiet snapshots; filter plugin/net logs; golden all green
- Delegate VM phi selection to LoopExecutor (borrow-safe)
- ResultBox migration: remove legacy box_trait::ResultBox paths
- VM BoxRef arithmetic fallbacks via toString().parse::<i64>()
- Bridge BoxCall(InstanceBox) to Class.method/arity in VM
- Fix Effects purity (READ -> readonly, not pure)
- Mark Catch as CONTROL to prevent DCE; Try/Catch test green
- Add env-gated debug logs (effects, verifier, mir-printer, trycatch, ref, bin)
- Update CURRENT_TASK with progress and next steps
2025-08-26 05:49:23 +09:00
144974ede7
Tests(MIR): add lightweight dump checks for BoxCall (.push) and Await to improve regression coverage without brittle snapshots.
2025-08-25 22:00:08 +09:00
f665787511
Tests(MIR): add extern_call console.log lowering test and verbose MIR dump assertion.
2025-08-25 20:19:04 +09:00
317e6af0bf
MIR: add loop_api facade trait and simple lowering helper; implement LoopBuilderApi for legacy MirBuilder to enable adapter-based migration.
2025-08-25 20:16:42 +09:00
46d47e2948
Tests(MIR): add lowering tests ensuring TypeOp for print(isType(...)) and print(obj.is(...)); note: cargo check passes, test harness currently blocked by CLI config fields unrelated to MIR changes.
2025-08-25 20:09:12 +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
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
bab57e7c07
🎉 feat: ChatGPT5による奇跡の全テスト修復完了!
...
- instance_v2移行で破綻していた440個のテストを30分で全修正
- git巻き戻しレベルの状況から完全復活
- 人間には不可能な速度での大規模整合性修正
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-20 04:45:26 +09:00