nyash-codex
2bdf1abe78
feat(mir): Phase 1 - Loop Canonicalizer type definitions
Implements the foundation for loop canonicalization - a preprocessing
layer that decomposes AST loops into normalized skeleton representation
to prevent combinatorial explosion in pattern detection.
## Implementation (Phase 1)
Created `src/mir/loop_canonicalizer/mod.rs` with:
1. **Core Types**:
- `LoopSkeleton`: Canonical loop representation
- `SkeletonStep`: Step kinds (HeaderCond, BreakCheck, ContinueCheck, Update, Body)
- `UpdateKind`: Carrier update classification (ConstStep, Conditional, Arbitrary)
- `ExitContract`: Exit presence tracking (break/continue/return)
- `CarrierSlot`: Loop variables with roles and update rules
- `CarrierRole`: Semantic roles (Counter, Accumulator, ConditionVar, Derived)
- `CapturedSlot`: Outer scope variable capture
2. **Capability Guard**:
- `RoutingDecision`: Pattern selection with diagnostics
- `capability_tags` module: Standardized Fail-Fast vocabulary
(CAP_MISSING_CONST_STEP, CAP_MISSING_SINGLE_BREAK, etc.)
3. **Helper Methods**:
- Skeleton counting (break_checks, continue_checks)
- Carrier name extraction
- Exit contract queries
- Display implementations for debugging
4. **Unit Tests**: 6 tests covering all basic functionality
## Design Principles
- **Input**: AST only (no JoinIR dependencies)
- **Output**: LoopSkeleton only (no BlockId/ValueId)
- **Boundary**: Clear separation from lowering concerns
- **Fail-Fast**: Capability-based rejection with clear reasons
## Next Steps (Not in this commit)
- Phase 2: `LoopCanonicalizer::canonicalize(ast) -> Result<LoopSkeleton>`
- Phase 3: Test with skip_whitespace fixture
- Phase 4: Integration with existing JoinIR lowering
## Acceptance Criteria
✅ `cargo build --release` succeeds
✅ `cargo test --release --lib` passes (1039 tests)
✅ 6 new unit tests for loop_canonicalizer pass
✅ No regressions in existing tests
Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-16 04:59:26 +09:00
..
2025-12-16 04:37:47 +09:00
2025-11-21 06:25:17 +09:00
2025-12-08 23:43:26 +09:00
2025-12-11 20:54:33 +09:00
2025-11-30 04:35:40 +09:00
2025-12-15 23:27:24 +09:00
2025-12-14 03:36:45 +09:00
2025-12-11 20:54:33 +09:00
2025-12-16 04:59:26 +09:00
2025-12-14 19:02:18 +09:00
2025-11-30 14:30:28 +09:00
2025-12-11 20:54:33 +09:00
2025-12-11 20:54:33 +09:00
2025-12-11 20:54:33 +09:00
2025-12-16 04:07:17 +09:00
2025-11-30 09:38:28 +09:00
2025-12-16 03:33:56 +09:00
2025-11-24 15:02:51 +09:00
2025-11-21 06:25:17 +09:00
2025-12-11 17:16:10 +09:00
2025-12-13 05:34:56 +09:00
2025-12-16 04:07:17 +09:00
2025-12-07 23:45:55 +09:00
2025-12-03 13:59:06 +09:00
2025-12-03 13:59:06 +09:00
2025-11-21 06:25:17 +09:00
2025-12-05 17:22:14 +09:00
2025-12-15 22:03:34 +09:00
2025-09-17 07:43:07 +09:00
2025-11-30 04:35:40 +09:00
2025-12-05 15:45:42 +09:00
2025-12-12 16:40:20 +09:00
2025-12-16 03:33:56 +09:00
2025-11-24 14:17:02 +09:00
2025-12-16 04:59:26 +09:00
2025-11-24 14:17:02 +09:00
2025-09-17 07:43:07 +09:00
2025-12-03 13:59:06 +09:00
2025-11-30 04:35:40 +09:00
2025-12-05 19:39:54 +09:00
2025-11-24 15:02:51 +09:00
2025-09-24 09:30:42 +09:00
2025-11-24 15:02:51 +09:00
2025-11-21 06:25:17 +09:00
2025-11-17 09:45:03 +09:00
2025-11-24 15:02:51 +09:00
2025-11-21 06:25:17 +09:00
2025-12-03 13:59:06 +09:00