docs(joinir): Phase 232-239 documentation and ExprLowerer refinements
Documentation: - Move completion reports to docs/archive/reports/ - Add phase232-238 design/inventory documents - Update joinir-architecture-overview.md - Add doc-status-policy.md Code refinements: - ExprLowerer: condition catalog improvements - ScopeManager: boundary clarifications - CarrierInfo: cleanup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -146,31 +146,9 @@ impl<'a> ScopeManager for Pattern2ScopeManager<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Promoted LoopBodyLocal → Carrier lookup
|
||||
// If this variable was promoted, try to find its carrier equivalent
|
||||
if self.carrier_info.promoted_loopbodylocals.contains(&name.to_string()) {
|
||||
// Try naming conventions
|
||||
for carrier_name in &[
|
||||
format!("is_{}", name), // DigitPos pattern
|
||||
format!("is_{}_match", name), // Trim pattern
|
||||
] {
|
||||
// Check if it's the loop variable (unlikely but possible)
|
||||
if carrier_name == &self.carrier_info.loop_var_name {
|
||||
if let Some(id) = self.condition_env.get(&self.carrier_info.loop_var_name) {
|
||||
return Some(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise check carriers
|
||||
if let Some(carrier) = self.carrier_info.carriers.iter().find(|c| c.name == *carrier_name) {
|
||||
if let Some(join_id) = carrier.join_id {
|
||||
return Some(join_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
// 4. Promoted LoopBodyLocal → Carrier lookup(命名規約は CarrierInfo 側に集約)
|
||||
self.carrier_info
|
||||
.resolve_promoted_join_id(name)
|
||||
}
|
||||
|
||||
fn scope_of(&self, name: &str) -> Option<VarScopeKind> {
|
||||
@ -323,4 +301,36 @@ mod tests {
|
||||
assert_eq!(scope.lookup("temp"), Some(ValueId(200)));
|
||||
assert_eq!(scope.scope_of("temp"), Some(VarScopeKind::LoopBodyLocal));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pattern2_scope_manager_captured() {
|
||||
let mut condition_env = ConditionEnv::new();
|
||||
condition_env.insert("i".to_string(), ValueId(100));
|
||||
condition_env.insert("len".to_string(), ValueId(201));
|
||||
|
||||
let mut captured_env = crate::mir::loop_pattern_detection::function_scope_capture::CapturedEnv::new();
|
||||
captured_env.add_var(CapturedVar {
|
||||
name: "len".to_string(),
|
||||
host_id: ValueId(42),
|
||||
is_immutable: true,
|
||||
});
|
||||
|
||||
let carrier_info = CarrierInfo {
|
||||
loop_var_name: "i".to_string(),
|
||||
loop_var_id: ValueId(1),
|
||||
carriers: vec![],
|
||||
trim_helper: None,
|
||||
promoted_loopbodylocals: vec![],
|
||||
};
|
||||
|
||||
let scope = Pattern2ScopeManager {
|
||||
condition_env: &condition_env,
|
||||
loop_body_local_env: None,
|
||||
captured_env: Some(&captured_env),
|
||||
carrier_info: &carrier_info,
|
||||
};
|
||||
|
||||
assert_eq!(scope.lookup("len"), Some(ValueId(201)));
|
||||
assert_eq!(scope.scope_of("len"), Some(VarScopeKind::Captured));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user