refactor(joinir): drop unused break helper wrappers
This commit is contained in:
@ -18,9 +18,15 @@
|
||||
//! - Break condition analysis moved to `break_condition_analyzer.rs`
|
||||
//! - This module now focuses on high-level feature extraction
|
||||
//! - Delegates to specialized analyzers for break/continue logic
|
||||
//!
|
||||
//! # Boundary (Phase 110)
|
||||
//!
|
||||
//! - **Routing SSOT**: Pattern routing and feature classification use this module (and
|
||||
//! `BreakConditionAnalyzer`) as the SSOT in production code paths.
|
||||
//! - **Structure SSOT**: `crate::mir::control_tree` (StepTree) describes *control structure only*
|
||||
//! and must not drive routing decisions yet; it is used for dev-only observation and parity checks.
|
||||
|
||||
use crate::ast::{ASTNode, BinaryOperator, LiteralValue};
|
||||
use crate::mir::loop_pattern_detection::break_condition_analyzer::BreakConditionAnalyzer;
|
||||
use crate::mir::loop_pattern_detection::LoopFeatures;
|
||||
|
||||
/// Detect if a loop body contains continue statements
|
||||
@ -267,66 +273,6 @@ fn has_break_node(node: &ASTNode) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Phase 170-B: Check if break is in else clause
|
||||
///
|
||||
/// Phase 33-23: Delegated to BreakConditionAnalyzer
|
||||
///
|
||||
/// Helper function to determine if a break statement is in the else clause
|
||||
/// of an if-else statement, as opposed to the then clause.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `body` - Loop body statements to search
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// `true` if an `if ... else { break }` pattern is found
|
||||
pub(crate) fn has_break_in_else_clause(body: &[ASTNode]) -> bool {
|
||||
BreakConditionAnalyzer::has_break_in_else_clause(body)
|
||||
}
|
||||
|
||||
/// Phase 170-B: Extract break condition from loop body
|
||||
///
|
||||
/// Phase 33-23: Delegated to BreakConditionAnalyzer
|
||||
///
|
||||
/// Searches for the first break pattern in an if statement:
|
||||
/// - `if <condition> { break }` - returns <condition>
|
||||
/// - `if <condition> { ... } else { break }` - returns `<condition>` (caller must negate)
|
||||
///
|
||||
/// This is used to delegate break condition lowering to `condition_to_joinir`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `body` - Loop body statements to search
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// `Some(&ASTNode)` - The condition AST node (not negated)
|
||||
/// `None` - No break statement found or break is not in a simple if statement
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```nyash
|
||||
/// // Pattern 1: if condition { break }
|
||||
/// loop(i < 3) {
|
||||
/// if i >= 2 { break } // <- Returns the "i >= 2" condition
|
||||
/// i = i + 1
|
||||
/// }
|
||||
///
|
||||
/// // Pattern 2: if condition { ... } else { break }
|
||||
/// loop(start < end) {
|
||||
/// if ch == " " { start = start + 1 } else { break }
|
||||
/// // <- Returns the "(ch == " ")" condition (caller must negate)
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// If you need a normalized break condition as an owned AST node
|
||||
/// ("break when <cond> is true"), use
|
||||
/// `BreakConditionAnalyzer::extract_break_condition_node`.
|
||||
pub(crate) fn extract_break_condition(body: &[ASTNode]) -> Option<&ASTNode> {
|
||||
BreakConditionAnalyzer::extract_break_condition(body).ok()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user