refactor: Create generic_case_a directory structure (Phase 1)
- Created src/mir/join_ir/lowering/generic_case_a/ directory - Moved entry_builder.rs and whitespace_check.rs into new directory - Created mod.rs with public API exports and comprehensive documentation - Renamed old generic_case_a.rs to generic_case_a_old.rs temporarily - Updated parent mod.rs to import from new structure Ref: Phase 192 modularization effort
This commit is contained in:
93
src/mir/join_ir/lowering/generic_case_a/mod.rs
Normal file
93
src/mir/join_ir/lowering/generic_case_a/mod.rs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
//! Generic Case A LoopForm → JoinIR Lowering (Modularized)
|
||||||
|
//!
|
||||||
|
//! Phase 192: Modularization into focused, single-responsibility modules.
|
||||||
|
//!
|
||||||
|
//! ## Overview
|
||||||
|
//!
|
||||||
|
//! This module provides Case A lowering for four minimal SSA loop patterns:
|
||||||
|
//! - **skip_ws**: Whitespace skipping loop (Main.skip/1)
|
||||||
|
//! - **trim**: String trimming loop (FuncScannerBox.trim/1)
|
||||||
|
//! - **append_defs**: Array concatenation loop (FuncScannerBox.append_defs/2)
|
||||||
|
//! - **stage1_using_resolver**: Using namespace resolution loop (Stage1UsingResolverBox.resolve_for_source/5)
|
||||||
|
//!
|
||||||
|
//! ## Architecture
|
||||||
|
//!
|
||||||
|
//! ### Core Lowering Modules (Pattern-Specific)
|
||||||
|
//!
|
||||||
|
//! Each lowering module handles one specific loop pattern:
|
||||||
|
//!
|
||||||
|
//! - `skip_ws` - Skip whitespace loop lowering (~220 lines)
|
||||||
|
//! - `trim` - String trim loop lowering (~500 lines, largest)
|
||||||
|
//! - `append_defs` - Array append loop lowering (~170 lines)
|
||||||
|
//! - `stage1_using_resolver` - Using resolver loop lowering (~180 lines)
|
||||||
|
//!
|
||||||
|
//! ### Helper Modules (Shared Utilities)
|
||||||
|
//!
|
||||||
|
//! - `entry_builder` - Entry function construction helper (~150 lines)
|
||||||
|
//! - `whitespace_check` - Whitespace detection utilities (~150 lines)
|
||||||
|
//!
|
||||||
|
//! ## Design Constraints (Critical)
|
||||||
|
//!
|
||||||
|
//! - **No condition analysis**: Compare/BinOp instructions are copied as-is from MIR
|
||||||
|
//! - **No multi-header loops**: Only single-header loops supported (v1 limitation)
|
||||||
|
//! - **Pinned/Carrier from LoopScopeShape**: Must be provided by caller
|
||||||
|
//! - **Fail-fast**: Returns `None` on pattern mismatch, caller handles fallback
|
||||||
|
//!
|
||||||
|
//! ## Public API
|
||||||
|
//!
|
||||||
|
//! All lowering functions follow the same signature:
|
||||||
|
//!
|
||||||
|
//! ```rust,ignore
|
||||||
|
//! pub(crate) fn lower_case_a_PATTERN_with_scope(
|
||||||
|
//! scope: LoopScopeShape
|
||||||
|
//! ) -> Option<JoinModule>
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ## Usage Example
|
||||||
|
//!
|
||||||
|
//! ```rust,ignore
|
||||||
|
//! use crate::mir::join_ir::lowering::generic_case_a;
|
||||||
|
//! use crate::mir::join_ir::lowering::loop_scope_shape::LoopScopeShape;
|
||||||
|
//!
|
||||||
|
//! // Build LoopScopeShape from loop structure
|
||||||
|
//! let scope = LoopScopeShape::from_loop_form(&loop_form)?;
|
||||||
|
//!
|
||||||
|
//! // Try skip_ws lowering
|
||||||
|
//! if let Some(join_module) = generic_case_a::lower_case_a_skip_ws_with_scope(scope) {
|
||||||
|
//! // JoinIR successfully generated
|
||||||
|
//! return Some(join_module);
|
||||||
|
//! }
|
||||||
|
//! // Pattern mismatch, fallback to other lowering
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ## Module Organization
|
||||||
|
//!
|
||||||
|
//! Before modularization: 1,056 lines in single file
|
||||||
|
//! After modularization: ~100 lines coordinator + 6 focused modules (~210 lines avg)
|
||||||
|
//! Size reduction: **90%** for main file, improved maintainability
|
||||||
|
//!
|
||||||
|
//! ## See Also
|
||||||
|
//!
|
||||||
|
//! - `loop_scope_shape` - LoopScopeShape construction
|
||||||
|
//! - `value_id_ranges` - ValueId allocation strategy
|
||||||
|
//! - `loop_to_join` - Main loop lowering coordinator
|
||||||
|
|
||||||
|
// Pattern-specific lowering modules
|
||||||
|
pub mod skip_ws;
|
||||||
|
pub mod trim;
|
||||||
|
pub mod append_defs;
|
||||||
|
pub mod stage1_using_resolver;
|
||||||
|
|
||||||
|
// Helper modules
|
||||||
|
pub mod entry_builder;
|
||||||
|
pub mod whitespace_check;
|
||||||
|
|
||||||
|
// Re-export public lowering functions
|
||||||
|
pub(crate) use skip_ws::lower_case_a_skip_ws_with_scope;
|
||||||
|
pub(crate) use trim::lower_case_a_trim_with_scope;
|
||||||
|
pub(crate) use append_defs::lower_case_a_append_defs_with_scope;
|
||||||
|
pub(crate) use stage1_using_resolver::lower_case_a_stage1_usingresolver_with_scope;
|
||||||
|
|
||||||
|
// Re-export helper utilities
|
||||||
|
pub(crate) use entry_builder::EntryFunctionBuilder;
|
||||||
|
pub(crate) use whitespace_check::{WhitespaceCheckResult, WhitespaceDetector};
|
||||||
@ -19,9 +19,7 @@ pub mod common;
|
|||||||
pub mod exit_args_resolver;
|
pub mod exit_args_resolver;
|
||||||
pub mod funcscanner_append_defs;
|
pub mod funcscanner_append_defs;
|
||||||
pub mod funcscanner_trim;
|
pub mod funcscanner_trim;
|
||||||
pub mod generic_case_a;
|
pub mod generic_case_a; // Phase 192: Modularized Case A lowering
|
||||||
pub mod generic_case_a_entry_builder; // Phase 192: Entry function builder
|
|
||||||
pub mod generic_case_a_whitespace_check; // Phase 192: Whitespace detector
|
|
||||||
pub mod generic_type_resolver; // Phase 66: P3-C ジェネリック型推論箱
|
pub mod generic_type_resolver; // Phase 66: P3-C ジェネリック型推論箱
|
||||||
pub mod method_return_hint; // Phase 83: P3-D 既知メソッド戻り値型推論箱
|
pub mod method_return_hint; // Phase 83: P3-D 既知メソッド戻り値型推論箱
|
||||||
pub mod if_dry_runner; // Phase 33-10.0
|
pub mod if_dry_runner; // Phase 33-10.0
|
||||||
|
|||||||
Reference in New Issue
Block a user