|
|
6a3b6deb20
|
feat(anf): Phase 145 P0/P1/P2 - ANF (A-Normal Form) transformation
Implement ANF transformation for impure expressions to fix evaluation order:
Phase 145 P0 (Skeleton):
- Add anf/ module with contract/plan/execute 3-layer separation
- AnfDiagnosticTag, AnfOutOfScopeReason, AnfPlan enums
- Stub execute_box (always returns Ok(None))
- 11 unit tests pass
Phase 145 P1 (Minimal success):
- String.length() whitelist implementation
- BinaryOp + MethodCall pattern: x + s.length() → t = s.length(); result = x + t
- Exit code 12 verification (VM + LLVM EXE)
- 17 unit tests pass
Phase 145 P2 (Generalization):
- Recursive ANF for compound expressions
- Left-to-right, depth-first evaluation order
- Patterns: x + s.length() + z, s1.length() + s2.length()
- ANF strict mode (HAKO_ANF_STRICT=1)
- Diagnostic tags (joinir/anf/*)
- 21 unit tests pass, 0 regression
Also includes Phase 143 P2 (else symmetry) completion.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-19 16:19:49 +09:00 |
|
|
|
7030b110cb
|
feat(phase143/r0): Contract SSOT extraction - loop-if-exit pattern refactoring
Phase 143 R0: Refactor P0 to prevent if-branch explosion in P1/P2
**Key Changes**:
- New: loop_if_exit_contract.rs (LoopIfExitShape, LoopIfExitThen, OutOfScopeReason)
- Contract SSOT for pattern shape detection and exit action discrimination
- Separated unit tests to tests/phase143_loop_if_exit_contract.rs (8 tests)
- Removed embedded tests from implementation file
- Updated module declarations for contract and test modules
**Benefits**:
- Enum-driven pattern discrimination (no if-branch explosion)
- P1 extension: Add Continue via 1 enum variant + 1 match arm
- P2 extension: Add else via contract fields (linear growth, not exponential)
- Improved maintainability and code discoverability
**Verification**:
- cargo check: ✅ 0 errors
- Unit tests: ✅ 8/8 passed
- Documentation: ✅ Updated 10-Now.md and 30-Backlog.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
2025-12-19 06:33:56 +09:00 |
|
|
|
3f81640764
|
feat(normalization): Phase 143 P0 Step 1-2 - Pattern detection skeleton + routing
fast-smoke / fast (push) Has been cancelled
Phase 143-loopvocab P0: Steps 1-2 complete
Step 1: Pattern detection skeleton
- New file: src/mir/control_tree/normalized_shadow/loop_true_if_break_continue.rs
- Implements extract_loop_true_if_break() for pattern recognition
- Returns Ok(None) for minimal P0 scope (loop(true){ if(cond_pure) break } only)
- Unit tests for pattern detection and literal checks
Step 2: Routing integration
- Added module declaration in mod.rs
- Added import and routing in builder.rs
- Priority: Phase 131 (loop_true_break_once) → Phase 143 P0 (loop_true_if_break_continue) → Legacy
Status: Skeleton compiles ✅ (cargo check passes)
- Full JoinIR generation deferred to Steps 3-6
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
2025-12-19 05:52:19 +09:00 |
|
|
|
95daf230c4
|
refactor(normalized_shadow): Phase 138 - extract ReturnValueLowererBox (no behavior change)
Extract return value lowering logic to shared Box for SSOT:
New Files:
- common/return_value_lowerer_box.rs (~300 lines)
- ReturnValueLowererBox::lower_to_value_id()
- Supports: Variable, Integer literal, Add expression
- 5 comprehensive unit tests
- common/mod.rs (module export)
Modified Files:
- loop_true_break_once.rs
- Removed lower_return_value_to_vid() method (~115 lines)
- Added import: use super::common::return_value_lowerer_box::ReturnValueLowererBox
- Updated 2 call sites (post_k, k_exit)
- Updated SSOT documentation
- mod.rs
- Added pub mod common;
Code Reduction: ~115 lines removed from loop_true_break_once.rs
Tests:
- cargo test --lib: 1194 tests PASS (+5 new unit tests)
- Phase 137 regression: 6/6 PASS
- Phase 97 regression: 2/2 PASS
- Phase 131/135/136 regression: 3/3 PASS
Behavior: Unchanged (all Phase 136/137 fixtures/smokes PASS)
SSOT: common/return_value_lowerer_box.rs
Next: Phase 139 P0 - Migrate post_if_post_k.rs to ReturnValueLowererBox
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-19 00:55:51 +09:00 |
|
|
|
02c4c313e5
|
feat(control_tree): Phase 131 P1.5-P2 DirectValue exit reconnection
Implement DirectValue mode for Normalized shadow exit handling:
**P1.5 Changes**:
- Add ExitReconnectMode::DirectValue (skip exit PHI generation)
- Carry remapped_exit_values through merge result
- Update host variable_map directly with exit values
- Fix loop(true) { x = 1; break }; return x to return 1 correctly
**P2 Changes**:
- Normalize k_exit continuation entry/exit edges
- Rewrite TailCall(k_exit) → Jump(exit_block) for proper merge
- Add verify_all_terminator_targets_exist contract check
- Extend ExitLineReconnector to handle DirectValue mode
**Infrastructure**:
- tools/build_llvm.sh: Force TMPDIR under target/ (EXDEV mitigation)
- llvm_exe_runner.sh: Add exit_code verification support
- Phase 131 smokes: Update for dev-only + exit code validation
**Contracts**:
- PHI-free: Normalized path uses continuations only
- Exit values reconnect via remapped ValueIds
- Existing patterns unaffected (既定挙動不変)
Related: Phase 131 loop(true) break-once Normalized support
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-18 17:48:05 +09:00 |
|
|
|
b531a64d67
|
feat(control_tree): Phase 131 normalized loop(true) break-once builder (dev-only)
Implement Normalized shadow builder for loop(true) break-once pattern:
**New Module** (407 lines):
- src/mir/control_tree/normalized_shadow/loop_true_break_once.rs
- LoopTrueBreakOnceBuilderBox: loop(true) { <assign>* ; break } lowering
- PHI-free: env parameters + continuation-passing style
- Generated structure: main → loop_step → loop_body → k_exit
- Scope: Bool(true) literal condition only, break at end only
**Integration**:
- src/mir/control_tree/normalized_shadow/builder.rs
- Added lower_with_loop_support() for loop patterns
- try_lower_if_only() now falls through to loop support on capability reject
- src/mir/control_tree/normalized_shadow/mod.rs
- Module declaration added
**Contract**:
- Accepted: loop(true) { <assign of int literal/var/add>* ; break }
- Rejected (Ok(None)): continue, return in body, nested control flow
- Out of scope: general loop conditions, complex post-loop statements
**Limitations**:
- Structure-only (dev-only observation mode)
- Execution path not yet wired (follow-up phase required)
- Shadow JoinModule generation working, structural verification passing
- Unit tests: 1155/1155 PASS
Related: Phase 131 P0
|
2025-12-18 09:36:38 +09:00 |
|
|
|
80df1cccd4
|
feat(control_tree): Phase 129-C post-if via post_k continuation
|
2025-12-18 08:33:56 +09:00 |
|
|
|
df23a52916
|
refactor(control_tree): modularize normalized_shadow dev pipeline
|
2025-12-18 08:14:49 +09:00 |
|
|
|
89c2915fa0
|
feat(control_tree): Phase 126 AvailableInputsCollectorBox
- Collect available_inputs from function params + CapturedEnv (SSOT)
- BTreeMap for deterministic order
- Box-first modularization with unit tests (5 tests PASS)
- Source priority: params > CapturedEnv
- No AST inference (only pre-computed sources)
|
2025-12-18 06:43:27 +09:00 |
|
|
|
1e5432f61a
|
feat(control_tree): add StepTree→Normalized shadow lowerer (if-only, dev-only)
|
2025-12-18 04:31:41 +09:00 |
|