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:
nyash-codex
2025-12-16 03:48:44 +09:00
parent 44b20bfe28
commit 9170f0a85d
27 changed files with 146 additions and 174 deletions

View File

@ -429,7 +429,7 @@ impl super::MirBuilder {
// Register at least Future<Unknown> to avoid later fail-fast type inference panics.
self.type_ctx.value_types
.insert(future_id, MirType::Future(Box::new(MirType::Unknown)));
self.variable_map.insert(variable.clone(), future_id);
self.variable_ctx.variable_map.insert(variable.clone(), future_id);
if let Some(reg) = self.current_slot_registry.as_mut() {
reg.ensure_slot(&variable, None);
}
@ -448,7 +448,7 @@ impl super::MirBuilder {
.unwrap_or(MirType::Unknown);
self.type_ctx.value_types
.insert(future_id, MirType::Future(Box::new(inner)));
self.variable_map.insert(variable.clone(), future_id);
self.variable_ctx.variable_map.insert(variable.clone(), future_id);
if let Some(reg) = self.current_slot_registry.as_mut() {
reg.ensure_slot(&variable, None);
}
@ -478,7 +478,7 @@ impl super::MirBuilder {
// me: resolve to param if present; else symbolic const (stable mapping)
pub(super) fn build_me_expression(&mut self) -> Result<ValueId, String> {
if let Some(id) = self.variable_map.get("me").cloned() {
if let Some(id) = self.variable_ctx.variable_map.get("me").cloned() {
return Ok(id);
}
let me_tag = if let Some(ref cls) = self.current_static_box {
@ -487,7 +487,7 @@ impl super::MirBuilder {
"__me__".to_string()
};
let me_value = crate::mir::builder::emission::constant::emit_string(self, me_tag);
self.variable_map.insert("me".to_string(), me_value);
self.variable_ctx.variable_map.insert("me".to_string(), me_value);
if let Some(reg) = self.current_slot_registry.as_mut() {
reg.ensure_slot("me", None);
}