feat(joinir): Phase 282 P3 - Pattern1 ExtractionBased Migration
Migrated Pattern1 (Simple While Loop) from StructureBased to ExtractionBased detection, creating a migration template for Pattern2-5. **Changes**: 1. Created extractors/mod.rs - Module entry point with design principles 2. Created extractors/pattern1.rs - Pure extraction functions with 4-phase validation 3. Updated pattern1_minimal.rs - can_lower() + lower() use extraction 4. Updated mod.rs - Registered extractors module **Pattern1Parts Design** (Lightweight): - Stores only loop_var (AST reused from ctx, no heavy copies) - Validation: 比較条件 + no break/continue/if-else + 単純step (i = i ± const) - Return statements allowed (not loop control flow) **4-Phase Validation**: 1. Validate condition structure (比較演算, left=variable) 2. Validate body (no break/continue/if-else-phi) 3. Validate step pattern (simple i = i ± const only) 4. Extract loop variable **Safety Valve Strategy**: - pattern_kind as O(1) early rejection guard - Extraction as SSOT authoritative check - Re-extraction in lower() (no caching from can_lower) **Testing**: - Unit tests: 3/3 PASS - Build: 0 errors - Regression: 45/46 PASS (zero regression) **Migration Template**: - Result<Option<Parts>, String> return type (Pattern8/9 model) - Pure functions (no builder mutations) - Fail-Fast error handling (Err for logic bugs, Ok(None) for non-matches) 🎉 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -53,6 +53,7 @@
|
||||
//! - 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 extractors; // Phase 282 P3: Common extraction interfaces
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user