|
|
7be72e9e14
|
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>
|
2025-12-07 21:32:50 +09:00 |
|
|
|
1356b61ff7
|
feat(joinir): Phase 170-D-impl-1 LoopConditionScopeBox skeleton creation
Implement the LoopConditionScope analysis infrastructure for Pattern2/4 validation:
New module:
- src/mir/loop_pattern_detection/loop_condition_scope.rs (220 lines)
Types:
- CondVarScope enum: LoopParam, OuterLocal, LoopBodyLocal
- CondVarInfo: Variable name + scope classification
- LoopConditionScope: Collection of analyzed variables with helper methods
Box implementation (LoopConditionScopeBox):
- analyze(): Main entry point - extracts and classifies condition variables
- extract_vars(): Recursive AST traversal to find all variable references
- is_outer_local(): Heuristic for outer scope detection (phase 170-D simplified)
Helper methods:
- has_loop_body_local(): Check for unsupported loop-body variables
- all_in(): Validate scope compatibility
- var_names(): Get variable set
- add_var(): Add with deduplication
Tests: 5 unit tests for core functionality
Architecture: Refactored loop_pattern_detection.rs → loop_pattern_detection/mod.rs
for modular organization.
Build: ✅ Passed with no errors
🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
2025-12-07 21:29:19 +09:00 |
|