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:
@ -54,16 +54,16 @@ pub fn ensure(builder: &mut MirBuilder, v: ValueId, kind: LocalKind) -> ValueId
|
||||
}
|
||||
|
||||
// CRITICAL FIX: If `v` is from a pinned slot, check if there's a PHI value for that slot
|
||||
// in the current block's variable_map. If so, use the PHI value directly instead of
|
||||
// in the current block's variable_ctx.variable_map. If so, use the PHI value directly instead of
|
||||
// emitting a Copy from the old value (which might not be defined in this block).
|
||||
// Try to detect pinned slots for this value and redirect to the latest slot value.
|
||||
// 1) First, look for "__pin$" entries in variable_map that still point to v.
|
||||
// 1) First, look for "__pin$" entries in variable_ctx.variable_map that still point to v.
|
||||
// 2) If not found, consult builder.pin_slot_names to recover the slot name
|
||||
// and then look up the current ValueId for that slot.
|
||||
let mut slot_name_opt: Option<String> = None;
|
||||
|
||||
let names_for_v: Vec<String> = builder
|
||||
.variable_map
|
||||
.variable_ctx.variable_map
|
||||
.iter()
|
||||
.filter(|(k, &vid)| vid == v && k.starts_with("__pin$"))
|
||||
.map(|(k, _)| k.clone())
|
||||
@ -76,7 +76,7 @@ pub fn ensure(builder: &mut MirBuilder, v: ValueId, kind: LocalKind) -> ValueId
|
||||
}
|
||||
|
||||
if let Some(slot_name) = slot_name_opt {
|
||||
if let Some(¤t_val) = builder.variable_map.get(&slot_name) {
|
||||
if let Some(¤t_val) = builder.variable_ctx.variable_map.get(&slot_name) {
|
||||
if current_val != v {
|
||||
// The slot has been updated (likely by a PHI or header rewrite).
|
||||
// Use the updated value instead of the stale pinned ValueId.
|
||||
|
||||
Reference in New Issue
Block a user