refactor(mir): Remove VariableContext legacy fields (Phase 2-6/7)
完全移行→削除の安全順序(Option C)に従い、VariableContext の deprecated フィールドと sync helpers を完全削除。 ## Changes - Migrated all 66+ access sites to variable_ctx.variable_map - Removed 1 deprecated field (variable_map) from MirBuilder - Removed 2 sync helpers (sync_variable_ctx_to_legacy, sync_legacy_to_variable_ctx) - Fixed BoxCompilationContext.variable_map references (kept as-is, different scope) - Fixed ExitBindingBuilder.variable_map references (kept as-is, local field) - Updated observer.rs to use variable_map() accessor method ## JoinIR Integration Verified - CarrierInfo::from_variable_map() works correctly - ExitLine contract maintained (Phase 132-135) - NYASH_TRACE_VARMAP debug support preserved - Pattern 1-5 lowering all functional ## Tests - cargo test --release --lib: 1033 passed, 0 failed - phase135_trim_mir_verify.sh: PASS (MIR SSA/ValueId OK) - cargo build --release: SUCCESS - Deprecation warnings: reduced (86 remaining, from other contexts) ## Statistics - 27 files changed - 146 insertions(+), 174 deletions(-) - Net: -28 lines Phase 2 Progress: 6/7 contexts complete (86%) - ✅ MetadataContext - ✅ CoreContext - ✅ TypeContext - ✅ ScopeContext - ✅ BindingContext - ✅ VariableContext (this commit) - ⏳ CompilationContext (Phase 2-7 next) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -132,31 +132,31 @@ impl super::MirBuilder {
|
||||
if false && !self.suppress_pin_entry_copy_next {
|
||||
// Keep old code for reference
|
||||
// First pass: copy all pin slots and remember old->new mapping
|
||||
let names: Vec<String> = self.variable_map.keys().cloned().collect();
|
||||
let names: Vec<String> = self.variable_ctx.variable_map.keys().cloned().collect();
|
||||
let mut pin_renames: Vec<(super::ValueId, super::ValueId)> = Vec::new();
|
||||
for name in names.iter() {
|
||||
if !name.starts_with("__pin$") {
|
||||
continue;
|
||||
}
|
||||
if let Some(&src) = self.variable_map.get(name) {
|
||||
if let Some(&src) = self.variable_ctx.variable_map.get(name) {
|
||||
let dst = self.next_value_id();
|
||||
self.emit_instruction(super::MirInstruction::Copy { dst, src })?;
|
||||
crate::mir::builder::metadata::propagate::propagate(self, src, dst);
|
||||
self.variable_map.insert(name.clone(), dst);
|
||||
self.variable_ctx.variable_map.insert(name.clone(), dst);
|
||||
pin_renames.push((src, dst));
|
||||
}
|
||||
}
|
||||
// Second pass: update any user variables that pointed to old pin ids to the new ones
|
||||
if !pin_renames.is_empty() {
|
||||
let snapshot: Vec<(String, super::ValueId)> = self
|
||||
.variable_map
|
||||
.variable_ctx.variable_map
|
||||
.iter()
|
||||
.filter(|(k, _)| !k.starts_with("__pin$"))
|
||||
.map(|(k, &v)| (k.clone(), v))
|
||||
.collect();
|
||||
for (k, v) in snapshot.into_iter() {
|
||||
if let Some((_, newv)) = pin_renames.iter().find(|(oldv, _)| *oldv == v) {
|
||||
self.variable_map.insert(k, *newv);
|
||||
self.variable_ctx.variable_map.insert(k, *newv);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -460,7 +460,7 @@ impl super::MirBuilder {
|
||||
// LocalSSA uses this to redirect old pinned values to the latest slot value.
|
||||
self.pin_slot_names.insert(v, slot_name.clone());
|
||||
self.pin_slot_names.insert(dst, slot_name.clone());
|
||||
self.variable_map.insert(slot_name, dst);
|
||||
self.variable_ctx.variable_map.insert(slot_name, dst);
|
||||
Ok(dst)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user