|
|
694a5ebadd
|
fix(phase161): Use ArrayBox.get() instead of at() for VM compatibility
- Replace .at() with .get() in mir_analyzer.hako (10 occurrences)
- Fix test_rep1_inline.hako and test_mir_analyzer.hako
- Builtin ArrayBox only supports .get(), not .at()
Phase 161-2 MIR JSON parsing tests now pass:
- JSON object parsing: PASS
- functions array extraction: PASS
- Function name extraction: PASS
- blocks extraction: PASS
- PHI instruction detection: PASS (found PHI at block=10 dst=r30)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-04 20:13:21 +09:00 |
|
|
|
9f2c791f2a
|
fix(json_parser): Eliminate _parse_number() infinite loop with flat control flow
Root cause: Nested-if-in-loop pattern triggered MIR compiler bug
- `if parsing_done == 1 { break }` inside loop caused infinite execution
- Flag variable approach created 2-level nesting that MIR couldn't handle
Fix: Refactored to flat control flow
- Removed `parsing_done` flag variable
- Inverted condition: check exit first (`digit_pos < 0 → break`)
- Direct break without nesting
- Moved `digits` constant outside loop (optimization)
Result:
- Lines: 28 → 15 (-46% complexity)
- Nesting: 2 levels → 1 level
- MIR-safe: No nested-if-in-loop pattern
This unblocks Phase 161-2 full MIR JSON parsing (rep1_if_simple.mir.json 8.5KB)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-04 20:00:27 +09:00 |
|
|
|
3c6797c1fb
|
feat(phase161): Add MirAnalyzerBox implementation (Phase 161-2 基本実装)
Task先生による Phase 161-2 実装成果:
**tools/hako_shared/mir_analyzer.hako** (375行)
- MirAnalyzerBox: MIR JSON v1 パーサー&アナライザー
- Core Methods:
- birth(mirJsonText): JSON パース&キャッシュ
- validateSchema(): MIR v1 構造検証
- summarize_function(funcIndex): メタデータ抽出
- count_phis(funcIndex): PHI 命令検出
- count_loops(funcIndex): CFG backward edge によるループ検出
**テストインフラ**
- test_mir_analyzer.hako: テストハーネスフレームワーク
- test_rep1_inline.hako: インラインテスト (rep1_if_simple)
- rep1_if_simple.mir.json: MIR JSON テストデータ (8.5KB)
- rep2_loop_simple.mir.json: ループパターンテストデータ (9.6KB)
**箱理論適用**
- 箱化: MirAnalyzerBox = MIR 分析専任(単一責務)
- 境界: JsonParserBox との完全分離
- Fail-Fast: 明示的エラー、フォールバック無し
- 遅延SG: _functions キャッシュ、オンデマンド計算
**発見された課題**
- JsonParserBox._parse_number() 無限ループ問題(次タスクで対処)
- VM ステップ予算超過でフル MIR JSON テスト一時ブロック
Status: Phase 161-2 80%完了(コア実装OK、テスト検証はJsonParser修正後)
Next: _parse_number() 修正 → Phase 161-2 テスト完了 → Phase 161-3
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-04 19:55:55 +09:00 |
|
|
|
608693af7f
|
fix(json_parser): Fix infinite loop by working around MIR nested-if bug
🐛 バグ修正: JsonParserBox 無限ループ解消
**問題**:
- `vm step budget exceeded` エラーが発生
- `_parse_number()` で無限ループ
**根本原因**:
- MIR lowering の既知のバグ: ループ内のネスト if-else 文が無限ジャンプチェーンを生成
- bb11 → bb6 → bb4 の無条件ジャンプループ
- PHI 更新が実行されず、ループ変数が更新されない
**修正内容**:
1. `while` → `loop()` 構文に統一(10箇所)
2. ネスト if-else をフラット化(workaround):
- `_parse_number()`: `ch >= "0" && ch <= "9"` → `digits.indexOf(ch) >= 0`
- `_parse_string()`: ネスト if を分離
- `_unescape_string()`: `ch == "\\" && i + 1 < s.length()` をフラット化
**テスト**:
- json_parser.hako: RC 0 ✅
- ネスト if-else バグを回避して正常動作
**注記**:
- 根本修正(MIR lowering bug fix)は別タスク
- workaround で Phase 173 ブロック解除
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-04 17:42:57 +09:00 |
|
|
|
b8118f36ec
|
feat(hako_check): Phase 170-172 JsonParserBox design & implementation docs
📚 Phase 170-172 完全ドキュメント化!
📋 Phase 170: .hako JSON ライブラリ設計 & インベントリ
- 既存 JSON 利用箇所のインベントリ完了
- JsonParserBox API 草案確定
- 利用予定マッピング作成(96%削減見込み)
📋 Phase 171: JsonParserBox 実装
- JsonParserBox 実装完了 (454行)
- parse(), parse_object(), parse_array() 実装
- エスケープシーケンス対応
- テストケース作成
📋 Phase 172: 再利用拡大 & Program JSON v0 サポート
- ProgramJSONBox 実装
- parse_program() メソッド追加
- セルフホスト深度-2 インフラ確立
🎯 箱化モジュール化パターン完全適用!
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-04 16:55:11 +09:00 |
|
|
|
cec34d2485
|
feat(hako_shared): Phase 172 JsonParserBox expansion - Program JSON v0 support
🌐 JSON processing SSOT infrastructure established!
🔧 Implementation:
- parse_program() method added to JsonParserBox (lines 448-463)
- ProgramJSONBox wrapper type for type-safe Program JSON access
- Methods: get_version(), get_kind(), get_defs(), get_meta(), get_usings()
- Validates required fields (version, kind) for Program JSON v0
📊 Reuse candidate survey results:
- compiler.hako (543 lines): Emits Program JSON (not consumer)
- json_loader.hako (51 lines): Utility functions only
- json_v0_reader.hako (142 lines): MIR JSON parser (not Program JSON)
- Finding: No significant Program JSON v0 consumers in current codebase
✅ Verification:
- JsonParserBox.parse_program/1: Compiled successfully
- ProgramJSONBox methods: All compiled (birth, get_version, get_kind, etc.)
- json_parser.hako: Runs without errors (RC: 0)
🎯 Phase 172 Achievement:
- Established JSON processing standardization foundation
- Infrastructure ready for future selfhost depth-2 integration
- Boxed modularization pattern fully applied (SSOT + gradual extension)
📝 Documentation:
- NEW: phase172_implementation_results.md (comprehensive analysis)
- MOD: CURRENT_TASK.md (Phase 172 completion status)
🏗️ Next Phase (173+):
- to_json() reverse conversion
- Schema validation
- Full selfhost depth-2 JSON unification
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-04 16:35:34 +09:00 |
|