Files
hakorune/CURRENT_TASK.md
tomoaki 9336785680 feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support
## Phase 146 P0: ANF Routing SSOT Unified

**Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering

**Changes**:
- expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF)
- post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper
- contract.rs: Already had `CondLoweringFailed` out-of-scope reason

**Test Results**:  Phase 146 P0 smoke (exit 7), 0 regressions

## Phase 146 P1: Compare Operator Support

**Goal**: Enable ANF for condition expressions with Compare operators

**Changes**:
- joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1)
- expr_lowerer_box.rs: PureOnly scope ANF support (L56-66)
- execute_box.rs: Compare operator support (+122 lines)
  - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()`
  - Extended `normalize_and_lower()` for Compare

**Test Results**:  Phase 146 P1 smoke (exit 7 with flags), 0 regressions

## Phase 147 P0: Recursive Comparison ANF

**Goal**: Extend recursive ANF to Compare operators

**Changes**:
- contract.rs: Added `AnfParentKind::Compare` variant
- plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139)
  - Distinguishes Compare vs arithmetic BinaryOp

**Benefits**: Enables recursive ANF for comparisons
- `s.length() == 3` → `t = s.length(); if (t == 3)` 
- `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` 

## Implementation Summary

**Files Modified** (9 files, +253 lines, -25 lines = +228 net):
1. src/config/env/joinir_dev.rs (+28 lines)
2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines)
3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines)
4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines)
5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines)
6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines)
7. CURRENT_TASK.md
8. docs/development/current/main/10-Now.md
9. docs/development/current/main/30-Backlog.md

**Files Created** (7 files):
- apps/tests/phase146_p0_if_cond_unified_min.hako
- apps/tests/phase146_p1_if_cond_intrinsic_min.hako
- tools/smokes/.../phase146_p0_if_cond_unified_vm.sh
- tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh
- tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh
- tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh
- docs/development/current/main/phases/phase-146/README.md

**Acceptance Criteria**:  All met
- cargo build --release: PASS (0 errors, 0 warnings)
- Phase 145 regressions: PASS (exit 12, 18, 5)
- Phase 146 P0: PASS (exit 7)
- Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1)

**Architecture**:
- SSOT: ANF routing only in `lower_expr_with_scope()` L54-84
- Box-First: Phase 145 `anf/` module extended
- Legacy removed: post_if_post_k.rs unified with SSOT

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00

65 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# CURRENT_TASK (moved)
Status: SSOT
Scope: Repo root の旧リンク互換。現行の入口は `docs/development/current/main/10-Now.md`
- Now: `docs/development/current/main/10-Now.md`
- Backlog: `docs/development/current/main/30-Backlog.md`
---
## Handoff (current)
### 状況SSOT
- 現行の入口: `docs/development/current/main/10-Now.md`
- 次の候補: `docs/development/current/main/30-Backlog.md`
### 直近の道筋JoinIR / Normalized
### 設計方針メモSSOT候補
- ExprLowererBox式SSOT
- 役割: `AST(expr)``(prelude: Vec<Inst>, value: ValueId)`ANF含む
- pure/impure/whitelist/strict の契約を集約入口SSOT
- ConditionLowererBox条件→分岐SSOT
- 役割: `AST(cond)``BranchPlan`(短絡なら分岐語彙で組む)
- 評価順は ExprLowererBox に委譲ANFで順序固定
- `&&/||` は制御として扱い、式で無理しない
- ControlLowererBox制御SSOT
- 役割: `StepNode/ControlTree` → JoinIR継続 + env
- `if/loop` はここ、条件の中身は ConditionLowererBox に委譲
- Phase 139: if-only `post_k` の return lowering を `ReturnValueLowererBox` に統一DONE
- `docs/development/current/main/phases/phase-139/README.md`
- Phase 140: `NormalizedExprLowererBox` 初版pure expression のみDONE
- SSOT: `docs/development/current/main/design/normalized-expr-lowering.md`
- `docs/development/current/main/phases/phase-140/README.md`
- Phase 141 P0: impure 拡張点contractを SSOT 化Call/MethodCall はまだ out-of-scopeDONE
- `docs/development/current/main/phases/phase-141/README.md`
- Phase 141 P1: “既知 intrinsic だけ” を許可して段階投入DONE
- `docs/development/current/main/phases/phase-141/README.md`
- Phase 141 P1.5: known intrinsic registry + available_inputs 3-source merge + diagnosticsDONE
- `docs/development/current/main/phases/phase-141/README.md`
- Phase 142-loopstmt P0: 正規化単位を statementloop 1個へ寄せるDONE
- `docs/development/current/main/phases/phase-142-loopstmt/README.md`
- Phase 142-loopstmt P1: LLVM EXE smoke同 fixtureを追加DONE
- `docs/development/current/main/phases/phase-142-loopstmt/README.md`
- Phase 141 P2+: Call/MethodCalleffects + typingを分離して段階投入
- Historical context: `docs/development/current/main/investigations/joinir-generalization-study.md`
- Phase 143-loopvocab P0/P1: loop 内 if/break/continue の語彙追加DONE
- `docs/development/current/main/phases/phase-143-loopvocab/README.md`
- Phase 143-loopvocab P2: else 対称化B-C / C-BDONE
- `docs/development/current/main/phases/phase-143-loopvocab/README.md`
- Phase 145-anf P0/P1/P2: ANFimpure hoist + 再帰的線形化DONE
- `docs/development/current/main/phases/phase-145-anf/README.md`
- Phase 146in progress: Loop/If 条件式へ ANF を横展開(順序固定と診断)
- `docs/development/current/main/phases/phase-146/README.md`
## Resolved (historical)
### WSL EXDEV / cargo build failure (resolved)
- 2025-12-18: `Invalid cross-device link (os error 18)` により `cargo build` が失敗する事象があったが、`wsl --shutdown` 再起動後に復旧。
- 再発時のワークアラウンド: `tools/build_llvm.sh` は EXDEV を避けるため `TMPDIR``target/...` 配下へ寄せる。