feat(joinir): Phase 170-D-impl-2 Minimal analysis logic with condition_var_analyzer
Implement variable extraction and scope classification with Box separation: New module: - src/mir/loop_pattern_detection/condition_var_analyzer.rs (270 lines) Public API (pure functions): - extract_all_variables(): Recursive AST traversal for variable collection * Handles: Variable, UnaryOp, BinaryOp, MethodCall, FieldAccess, Index, If * Deduplicates via HashSet automatically * Returns all variable names found in expression - is_outer_scope_variable(): Scope classification heuristic * Phase 170-D simplified: checks pinned set and header-only definitions * Conservative: defaults to LoopBodyLocal if uncertain * Returns true only for definitely outer-scope variables Integration (LoopConditionScopeBox.analyze()): - Delegated to condition_var_analyzer functions - Maintains original 3-level classification (LoopParam / OuterLocal / LoopBodyLocal) - Cleaner separation: analyzer = pure logic, Box = orchestration Test coverage: - 12 unit tests in condition_var_analyzer * Variable extraction: single, multiple, nested, deduped * Unary/Binary operations * Literal handling * Scope classification with mocked LoopScopeShape * Pinned variable detection * Header-only and multi-block definitions Architecture improvements: - Pure functions enable independent testing and reuse - Fail-Fast principle: conservative scope classification - Phase 170-D design: simple heuristics sufficient for initial detection Build: ✅ Passed with no errors 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -752,5 +752,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 170-D: Loop Condition Scope Analysis Box
|
||||
// Phase 170-D: Loop Condition Scope Analysis Boxes
|
||||
pub mod loop_condition_scope;
|
||||
pub mod condition_var_analyzer;
|
||||
|
||||
Reference in New Issue
Block a user