feat(joinir): Phase 231 - ExprLowerer/ScopeManager pilot implementation
Pilot implementation of unified expression lowering for Pattern2 break conditions: New files: - scope_manager.rs (280 lines) - ScopeManager trait + Pattern2ScopeManager - expr_lowerer.rs (455 lines) - ExprLowerer with Condition context support Features: - Unified variable lookup across ConditionEnv/LoopBodyLocalEnv/CapturedEnv/CarrierInfo - Pre-validation of condition AST before lowering - Fail-safe design with fallback to legacy path - 8 new unit tests (all pass) Integration: - Pattern2 break condition uses ExprLowerer for pre-validation - Existing proven lowering path preserved - Zero impact on existing functionality (890/897 tests pass) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -529,9 +529,44 @@ impl MirBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 231: ExprLowerer pilot - pre-validate break condition
|
||||
// This is a VALIDATION-ONLY step. We check if ExprLowerer can handle the condition,
|
||||
// but still use the existing proven lowering path. Future phases will replace actual lowering.
|
||||
{
|
||||
use crate::mir::join_ir::lowering::scope_manager::{Pattern2ScopeManager, ScopeManager};
|
||||
use crate::mir::join_ir::lowering::expr_lowerer::{ExprLowerer, ExprContext, ExprLoweringError};
|
||||
|
||||
let scope_manager = Pattern2ScopeManager {
|
||||
condition_env: &env,
|
||||
loop_body_local_env: Some(&body_local_env),
|
||||
captured_env: Some(&captured_env),
|
||||
carrier_info: &carrier_info,
|
||||
};
|
||||
|
||||
// Try ExprLowerer validation (doesn't affect actual lowering yet)
|
||||
// Phase 231: This is data-gathering only - we want to see which patterns work
|
||||
match ExprLowerer::new(&scope_manager, ExprContext::Condition, self)
|
||||
.with_debug(debug)
|
||||
.lower(&effective_break_condition)
|
||||
{
|
||||
Ok(_value_id) => {
|
||||
eprintln!("[pattern2/phase231] ✓ ExprLowerer successfully validated break condition");
|
||||
}
|
||||
Err(ExprLoweringError::UnsupportedNode(msg)) => {
|
||||
eprintln!("[pattern2/phase231] ℹ ExprLowerer fallback (unsupported): {}", msg);
|
||||
// This is expected for complex patterns - not an error
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("[pattern2/phase231] ⚠ ExprLowerer validation error: {}", e);
|
||||
// Unexpected error - log but don't fail (legacy path will handle it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 169 / Phase 171-fix / Phase 172-3 / Phase 170-B: Call Pattern 2 lowerer with break_condition
|
||||
// Phase 33-14: Now returns (JoinModule, JoinFragmentMeta) for expr_result + carrier separation
|
||||
// Phase 176-3: Multi-carrier support - pass carrier_info and carrier_updates
|
||||
// Phase 231: ExprLowerer validated above, but we still use proven legacy lowering
|
||||
eprintln!(
|
||||
"[pattern2/before_lowerer] About to call lower_loop_with_break_minimal with carrier_info.loop_var_name='{}'",
|
||||
carrier_info.loop_var_name
|
||||
|
||||
Reference in New Issue
Block a user