From 3987aa5b063e2818613a9c68b4207af9f3310387 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Thu, 18 Dec 2025 00:30:01 +0900 Subject: [PATCH] refactor(joinir): drop unused break helper wrappers --- .../joinir/patterns/ast_feature_extractor.rs | 68 ++----------------- 1 file changed, 7 insertions(+), 61 deletions(-) diff --git a/src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs b/src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs index 5a1ee6ef..818aebac 100644 --- a/src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs +++ b/src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs @@ -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 { break }` - returns -/// - `if { ... } else { break }` - returns `` (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 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::*;