**Status**: Core carrier PHI issue partially resolved, debugging loop body **Progress**: ✅ Task 1: split_scan_minimal.rs Carriers-First ordering (6 locations) ✅ Task 2: pattern7_split_scan.rs boundary configuration (host/join inputs, exit_bindings, expr_result) ✅ Result now flows from k_exit to post-loop code (RC issue resolved) ⚠️ Loop body instruction execution needs review **Key Fixes**: 1. Fixed host_inputs/join_inputs to match main() params Carriers-First order 2. Added result to exit_bindings (CarrierRole::LoopState) 3. Added result back to loop_invariants for variable initialization 4. Added expr_result=join_exit_value_result for loop expression return 5. Fixed jump args to k_exit to include all 4 params [i, start, result, s] **Current Issue**: - Loop body type errors resolved (String vs Integer fixed) - New issue: Loop body computations (sep_len) undefined in certain blocks - Likely cause: JoinIR→MIR conversion of local variables needs review **Next Steps**: - Review JoinValueSpace allocation and ValueId mapping in conversion - Verify loop_step instruction ordering and block structure - May need to refactor bound computation or revisit split algorithm 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
109 lines
6.1 KiB
Rust
109 lines
6.1 KiB
Rust
//! Pattern lowerers for different loop constructs
|
|
//!
|
|
//! Phase 2: Extracted from control_flow.rs
|
|
//! - Pattern 1: Simple While Loop (pattern1_minimal.rs)
|
|
//! - Pattern 2: Loop with Conditional Break (pattern2_with_break.rs)
|
|
//! - Pattern 3: Loop with If-Else PHI (pattern3_with_if_phi.rs)
|
|
//! - Pattern 4: Loop with Continue (pattern4_with_continue.rs) [Phase 194+]
|
|
//!
|
|
//! Phase 194: Table-driven router for pattern dispatch
|
|
//! - Router module provides table-driven pattern matching
|
|
//! - Each pattern exports can_lower() and lower() functions
|
|
//! - See router.rs for how to add new patterns
|
|
//!
|
|
//! Phase 193: AST Feature Extraction Modularization
|
|
//! - ast_feature_extractor.rs: Pure function module for analyzing loop AST
|
|
//! - High reusability for Pattern 5-6 and pattern analysis tools
|
|
//!
|
|
//! Phase 193-4 / Phase 222.5-C: Exit Binding Builder
|
|
//! - exit_binding.rs: Fully boxified exit binding generation (orchestrator)
|
|
//! - exit_binding_validator.rs: CarrierInfo and ExitMeta validation
|
|
//! - exit_binding_constructor.rs: Exit binding construction and ValueId allocation
|
|
//! - exit_binding_applicator.rs: Boundary application logic
|
|
//! - Eliminates hardcoded variable names and ValueId assumptions
|
|
//! - Supports both single and multi-carrier loop patterns
|
|
//!
|
|
//! Phase 33-22: Common Pattern Infrastructure
|
|
//! - common_init.rs: CommonPatternInitializer for unified initialization
|
|
//! - conversion_pipeline.rs: JoinIRConversionPipeline for unified conversion flow
|
|
//!
|
|
//! Phase 171-172: Refactoring Infrastructure
|
|
//! - loop_scope_shape_builder.rs: Unified LoopScopeShape initialization (Issue 4)
|
|
//! - condition_env_builder.rs: Unified ConditionEnv construction (Issue 5)
|
|
//!
|
|
//! Phase 33-23: Pattern-Specific Analyzers (Stage 2)
|
|
//! - pattern4_carrier_analyzer.rs: Pattern 4 carrier analysis and normalization (Issue 2)
|
|
//!
|
|
//! Stage 3 + Issue 1: Trim Pattern Extraction
|
|
//! - trim_pattern_validator.rs: Trim pattern validation and whitespace check generation
|
|
//! - trim_pattern_lowerer.rs: Trim-specific JoinIR lowering
|
|
//!
|
|
//! Phase 179-B: Generic Pattern Framework
|
|
//! - pattern_pipeline.rs: Unified preprocessing pipeline for Patterns 1-4
|
|
//!
|
|
//! Phase 91 P5b: Escape Pattern Recognizer
|
|
//! - escape_pattern_recognizer.rs: P5b (escape sequence handling) pattern detection
|
|
//! - Extracted from ast_feature_extractor for improved modularity
|
|
//!
|
|
//! Phase 93/94: Pattern Policies
|
|
//! - policies/: Pattern recognition and routing decision (future expansion)
|
|
//! - Currently a placeholder directory for future policy box organization
|
|
//!
|
|
//! Phase 255 P2: Common Utilities
|
|
//! - common/: Shared helper functions (var() etc.) to eliminate code duplication
|
|
|
|
pub(in crate::mir::builder) mod common; // Phase 255 P2: Common AST helpers
|
|
pub(in crate::mir::builder) mod ast_feature_extractor;
|
|
pub(in crate::mir::builder) mod policies; // Phase 93/94: Pattern routing policies (future expansion)
|
|
pub(in crate::mir::builder) mod body_local_policy; // Phase 92 P3: promotion vs slot routing
|
|
pub(in crate::mir::builder) mod escape_pattern_recognizer; // Phase 91 P5b
|
|
pub(in crate::mir::builder) mod common_init;
|
|
pub(in crate::mir::builder) mod loop_true_counter_extractor; // Phase 104: loop(true) counter extraction for Pattern2
|
|
pub(in crate::mir::builder) mod read_digits_break_condition_box; // Phase 104: break cond normalization for read_digits(loop(true))
|
|
pub(in crate::mir::builder) mod pattern2_break_condition_policy_router; // Phase 105: policy router box for Pattern2 break condition
|
|
pub(in crate::mir::builder) mod pattern2_policy_router; // Phase 108: unified Pattern2 policy router (balanced/read_digits/default)
|
|
pub(in crate::mir::builder) mod pattern2_inputs_facts_box; // Phase 105: Pattern2 input facts (analysis only)
|
|
pub(in crate::mir::builder) mod pattern2_lowering_orchestrator; // Phase 105: Pattern2 orchestration (wiring/emission)
|
|
pub(in crate::mir::builder) mod pattern2_steps; // Phase 106: Pattern2 step boxes (pipeline SSOT)
|
|
pub(in crate::mir::builder) mod condition_env_builder;
|
|
pub(in crate::mir::builder) mod conversion_pipeline;
|
|
pub(in crate::mir::builder) mod exit_binding;
|
|
pub(in crate::mir::builder) mod exit_binding_applicator; // Phase 222.5-C
|
|
pub(in crate::mir::builder) mod exit_binding_constructor; // Phase 222.5-C
|
|
pub(in crate::mir::builder) mod exit_binding_validator; // Phase 222.5-C
|
|
pub(in crate::mir::builder) mod loop_scope_shape_builder;
|
|
pub(in crate::mir::builder) mod pattern1_minimal;
|
|
pub(in crate::mir::builder) mod pattern2_with_break;
|
|
pub(in crate::mir::builder) mod pattern3_with_if_phi;
|
|
pub(in crate::mir::builder) mod pattern4_carrier_analyzer;
|
|
pub(in crate::mir::builder) mod pattern4_with_continue;
|
|
pub(in crate::mir::builder) mod pattern5_infinite_early_exit; // Phase 131-11
|
|
pub(in crate::mir::builder) mod pattern6_scan_with_init; // Phase 254 P0: index_of/find/contains pattern
|
|
pub(in crate::mir::builder) mod pattern7_split_scan; // Phase 256 P0: split/tokenization with variable step
|
|
pub(in crate::mir::builder) mod pattern_pipeline;
|
|
pub(in crate::mir::builder) mod router;
|
|
pub(in crate::mir::builder) mod trim_loop_lowering; // Phase 180: Dedicated Trim/P5 lowering module
|
|
pub(in crate::mir::builder) mod trim_pattern_lowerer;
|
|
pub(in crate::mir::builder) mod trim_pattern_validator;
|
|
|
|
// Re-export router for convenience
|
|
pub(in crate::mir::builder) use router::{route_loop_pattern, LoopPatternContext};
|
|
|
|
// Phase 140-P4-A: Re-export for loop_canonicalizer SSOT (crate-wide visibility)
|
|
pub(crate) use ast_feature_extractor::detect_skip_whitespace_pattern;
|
|
|
|
// Phase 104: Re-export read_digits(loop(true)) detection for loop_canonicalizer
|
|
pub(crate) use ast_feature_extractor::detect_read_digits_loop_true_pattern;
|
|
|
|
// Phase 142-P1: Re-export continue pattern detection for loop_canonicalizer
|
|
pub(crate) use ast_feature_extractor::detect_continue_pattern;
|
|
|
|
// Phase 143-P0: Re-export parse_number pattern detection for loop_canonicalizer
|
|
pub(crate) use ast_feature_extractor::detect_parse_number_pattern;
|
|
|
|
// Phase 143-P1: Re-export parse_string pattern detection for loop_canonicalizer
|
|
pub(crate) use ast_feature_extractor::detect_parse_string_pattern;
|
|
|
|
// Phase 91 P5b: Re-export escape skip pattern detection for loop_canonicalizer
|
|
pub(crate) use ast_feature_extractor::detect_escape_skip_pattern;
|