refactor(joinir): Phase 223 cleanup - impl consolidation & comment cleanup

Improves code organization and readability after Phase 223-3 implementation.

## Task R-1: impl Block Consolidation

**loop_body_cond_promoter.rs**:
- Merged 2 separate impl blocks into single unified impl
- Added section headers for better organization:
  - Public API (extract_continue_condition, try_promote_for_condition)
  - Private Helpers (contains_continue)
- Improved logical flow and discoverability

## Task R-2: Phase Comment Cleanup

**pattern4_with_continue.rs**:
- Simplified Phase 223-3 comments (removed redundant phase numbers)
- Added concise section header explaining LoopBodyLocal promotion
- Clarified inline comments for better understanding
- Maintained implementation intent while reducing noise

## Impact

- No functional changes
- All tests PASS (5 cond_promoter tests, 8 pattern4 tests)
- Better code organization for future maintenance
- Cleaner git history for Phase 223

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-10 15:07:08 +09:00
parent 89a769198a
commit 9b3d2bf001
3 changed files with 250 additions and 39 deletions

View File

@ -85,6 +85,10 @@ pub enum ConditionPromotionResult {
pub struct LoopBodyCondPromoter;
impl LoopBodyCondPromoter {
// ========================================================================
// Public API
// ========================================================================
/// Extract continue condition from loop body
///
/// Finds the first if statement with continue in then-branch and returns its condition.
@ -123,33 +127,6 @@ impl LoopBodyCondPromoter {
None
}
/// Check if statements contain a continue statement
fn contains_continue(stmts: &[ASTNode]) -> bool {
for stmt in stmts {
match stmt {
ASTNode::Continue { .. } => return true,
ASTNode::If {
then_body,
else_body,
..
} => {
if Self::contains_continue(then_body) {
return true;
}
if let Some(else_stmts) = else_body {
if Self::contains_continue(else_stmts) {
return true;
}
}
}
_ => {}
}
}
false
}
}
impl LoopBodyCondPromoter {
/// Try to promote LoopBodyLocal variables in conditions
///
/// ## P0 Requirements (Category A-3)
@ -223,6 +200,35 @@ impl LoopBodyCondPromoter {
}
}
}
// ========================================================================
// Private Helpers
// ========================================================================
/// Check if statements contain a continue statement
fn contains_continue(stmts: &[ASTNode]) -> bool {
for stmt in stmts {
match stmt {
ASTNode::Continue { .. } => return true,
ASTNode::If {
then_body,
else_body,
..
} => {
if Self::contains_continue(then_body) {
return true;
}
if let Some(else_stmts) = else_body {
if Self::contains_continue(else_stmts) {
return true;
}
}
}
_ => {}
}
}
false
}
}
#[cfg(test)]