Commit Graph

8 Commits

Author SHA1 Message Date
c10ffa4c2b refactor(phi): Phase 58 ConservativeMerge inline into merge_all_vars
Phase 58: ConservativeMerge 本体削除

## 変更内容

- ConservativeMerge::analyze を phi_merge.rs の merge_all_vars 内にインライン化
- conservative.rs から struct と impl を削除(約95行削減)
- conservative.rs はドキュメントコメントのみ残す

## 技術的詳細

- all_vars: 全ブランチの変数ユニオン(Conservative戦略)
- changed_vars: 実際に変更された変数(決定的順序のためBTreeSet使用)
- Conservative ∘ Elimination = Minimal SSA 理論コメント保持

## 削減効果

- conservative.rs: 149行 → 57行(92行削減、62%削減)
- ConservativeMerge struct 完全削除
- テストコード 35行削除

## テスト結果

- JoinIR: 56 passed / 0 failed
- PHI関連テスト: 全PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 09:14:24 +09:00
50bb58f2a1 refactor(phi): Phase 57 PHI code reduction
## Changes

### 57-2-alt: Remove redundant ConservativeMerge call
- phi.rs called ConservativeMerge::analyze twice (once directly,
  once via merge_all_vars)
- Now merge_all_vars returns changed_vars, eliminating redundancy

### 57-3: Delete PhiMergeOps trait (dead code, 17 lines)
- PhiMergeOps trait was defined but never called
- Only impl in loop_builder.rs was unused
- PhiBuilderOps has replaced it

### 57-4: Add responsibility comments to infer_type_from_phi
- Document that it's the "last resort" for type inference
- Specify deletion conditions (JoinIR type annotations)

## Cumulative PHI reduction
- Phase 38: 90 lines
- Phase 40-4.1: 35 lines
- Phase 41-1: 99 lines
- Phase 47: 33 lines
- Phase 57: 17 lines (PhiMergeOps) + optimization
- Total: 365+ lines removed

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 09:04:42 +09:00
d3eff1fceb feat(joinir): Phase 45-46 read_quoted_from IfMerge implementation
Phase 45: read_quoted_from JoinIR Frontend/Bridge
- Implement lower_read_quoted_pattern() for Guard if + Loop with break + accumulator pattern
- Add T1-T4 Route B E2E tests (all PASS)
- Create phase45_read_quoted_fixture.hako for Route A testing

Phase 46: IfMerge extension for loop-internal if-body reassignment
- Add escape handling: if ch == "\\" { i = i+1; ch = s.substring(...) }
- Use IfMerge to merge i and ch after if-body (speculative execution)
- T5 PASS: "a\"b" → 'a"b' (escape handling works!)

Dev flags:
- HAKO_JOINIR_READ_QUOTED=1: Enable Phase 45 JoinIR route
- HAKO_JOINIR_READ_QUOTED_IFMERGE=1: Enable Phase 46 IfMerge escape handling

Test results (Route B):
- T1: "abc" → 'abc' 
- T2: "" → '' 
- T3: abc → '' 
- T4: xx"def" → 'def' 
- T5: "a\"b" → 'a"b' 

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:13:52 +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
7812c3d4c1 feat(phi): Phase 25.1 - BTreeMap移行 (21ファイル、80%決定性達成)
## 修正内容

### Core MIR/PHI (5ファイル)
- builder.rs: variable_map, value_types, value_origin_newbox
- context.rs: 3つのマップ
- loop_builder.rs: 3箇所
- loop_snapshot_manager.rs: snapshot マップ
- loop_snapshot_merge.rs: 2箇所

### MIR関連 (4ファイル)
- function.rs: FunctionMetadata.value_types
- resolver.rs: CalleeResolverBox
- guard.rs: CalleeGuardBox
- loop_common.rs: apply_increment_before_continue

### JSON Bridge (5ファイル)
- json_v0_bridge/lowering.rs
- json_v0_bridge/lowering/expr.rs
- json_v0_bridge/lowering/if_else.rs
- json_v0_bridge/lowering/merge.rs
- json_v0_bridge/lowering/try_catch.rs
- json_v0_bridge/mod.rs

### Printer & Providers (4ファイル)
- printer.rs, printer_helpers.rs
- host_providers/mir_builder.rs
- backend/mir_interpreter/handlers/extern_provider.rs

### Tests (3ファイル)
- phi_core/conservative.rs
- tests/json_program_loop.rs
- tests/mir_stage1_using_resolver_verify.rs (2テスト有効化)

## テスト結果
- mir_stage1_using_resolver_resolve_with_modules_map_verifies: 80%成功率
- 完全な決定性は未達成 (HashMap 86箇所、HashSet 63箇所が残存)

🐱 Generated with Claude Code
2025-11-22 05:33:40 +09:00
9a352a8f02 refactor(phi): Phase 25.1q - PhiMergeHelper unified PHI insertion
**Changes**:
1. Created phi_merge.rs - Unified PHI insertion helper
   - PhiMergeHelper struct for Conservative PHI strategy
   - merge_variable() - single variable merging
   - merge_all_vars() - batch variable merging
   - 280 lines of well-documented, reusable logic

2. Refactored phi.rs merge_modified_vars
   - Use PhiMergeHelper::merge_all_vars() instead of inline logic
   - Reduced from ~80 lines to ~15 lines (81% reduction!)
   - Eliminated PHI insertion duplication

**Benefits**:
- Single source of truth for PHI insertion logic
- Improved code clarity (Box-First theory applied)
- Foundation for future loop PHI unification
- Easy to test and maintain

**Testing**:
 mir_stage1_using_resolver_full_collect_entries_verifies passes
 mir_stage1_using_resolver_min_fragment_verifies passes
 Phase 25.1c/k SSA fix preserved
 MIR correctness verified

**Code Reduction**:
- Phase A-1: 25 lines (Conservative unification)
- Phase A-2: 65 lines (PhiMergeHelper)
- **Total: 90 lines reduced** (36% of 215 target!)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 10:46:07 +09:00