refactor(mir): Remove CompilationContext legacy fields (Phase 2-7/7) 🎉

Phase 2 完全完了!全 7 Context のレガシーフィールドを完全削除。

## Changes
- Migrated all access sites to comp_ctx.* (15 fields)
- Removed 15 deprecated fields:
  * compilation_context
  * current_static_box
  * user_defined_boxes
  * reserved_value_ids
  * fn_body_ast
  * weak_fields_by_box
  * property_getters_by_box
  * field_origin_class
  * field_origin_by_box
  * static_method_index
  * method_tail_index
  * method_tail_index_source_len
  * type_registry
  * current_slot_registry
  * plugin_method_sigs
- Removed initialization code (15 field inits)

## Phase 2 完了!🎉
- builder.rs: 1222 → 1127 lines (-95 lines net)
- Deprecation warnings: 86 → 0 (完全排除)
- 全 36 deprecated fields 削除完了
- 全 14 sync helpers 削除完了
- 7 Context 完全SSOT化

## Tests
- cargo build --release: SUCCESS
- cargo test --release --lib: 1033/1033 PASS 
- Deprecation warnings: 0 

Phase 2 Progress: 7/7 contexts complete (100%) 
-  MetadataContext
-  CoreContext
-  TypeContext
-  ScopeContext
-  BindingContext
-  VariableContext
-  CompilationContext (this commit) 🎉

Phase 136 Context Box化: 完全完了!

🤖 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 04:07:17 +09:00
parent 9170f0a85d
commit 990d00393e
18 changed files with 88 additions and 183 deletions

View File

@ -26,8 +26,8 @@ impl super::MirBuilder {
}
}
// Within this lowering, treat `me` receiver as this static box
let saved_static = self.current_static_box.clone();
self.current_static_box = Some(box_name.clone());
let saved_static = self.comp_ctx.current_static_box.clone();
self.comp_ctx.current_static_box = Some(box_name.clone());
// Look for the main() method
let out = if let Some(main_method) = methods.get("main") {
if let ASTNode::FunctionDeclaration { params, body, .. } = main_method {
@ -111,7 +111,7 @@ impl super::MirBuilder {
}
self.variable_ctx.variable_map.insert(p.clone(), pid);
// 関数スコープ SlotRegistry にも登録しておくよ(観測専用)
if let Some(reg) = self.current_slot_registry.as_mut() {
if let Some(reg) = self.comp_ctx.current_slot_registry.as_mut() {
let ty = self.type_ctx.value_types.get(&pid).cloned();
reg.ensure_slot(p, ty);
}
@ -121,13 +121,13 @@ impl super::MirBuilder {
"[build_static_main_box] Storing fn_body_ast with {} nodes for inline main()",
body.len()
);
self.fn_body_ast = Some(body.clone());
self.comp_ctx.fn_body_ast = Some(body.clone());
// Lower statements in order to preserve def→use
let lowered = self.cf_block(body.clone());
// Phase 200-C: Clear fn_body_ast after main() lowering
self.fn_body_ast = None;
self.comp_ctx.fn_body_ast = None;
self.variable_ctx.variable_map = saved_var_map;
lowered
@ -138,7 +138,7 @@ impl super::MirBuilder {
Err("static box must contain a main() method".to_string())
};
// Restore static box context
self.current_static_box = saved_static;
self.comp_ctx.current_static_box = saved_static;
out
}
@ -164,7 +164,7 @@ impl super::MirBuilder {
// Record weak fields for this box
if !weak_fields.is_empty() {
let set: HashSet<String> = weak_fields.into_iter().collect();
self.weak_fields_by_box.insert(name.clone(), set);
self.comp_ctx.weak_fields_by_box.insert(name.clone(), set);
}
// Reserve method slots for user-defined instance methods (deterministic, starts at 4)
@ -206,7 +206,7 @@ impl super::MirBuilder {
if let Some((k, prop)) = kind_and_prop {
use std::collections::HashMap;
let entry: &mut HashMap<String, super::PropertyKind> = self
.property_getters_by_box
.comp_ctx.property_getters_by_box
.entry(name.clone())
.or_insert_with(HashMap::new);
entry.insert(prop, k);