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:
@ -28,7 +28,7 @@ impl MirBuilder {
|
||||
eprintln!(
|
||||
"[builder] function-call name={} static_ctx={} in_fn={}",
|
||||
name,
|
||||
self.current_static_box.as_deref().unwrap_or(""),
|
||||
self.comp_ctx.current_static_box.as_deref().unwrap_or(""),
|
||||
cur_fun
|
||||
);
|
||||
}
|
||||
@ -507,7 +507,7 @@ impl MirBuilder {
|
||||
name: &str,
|
||||
arg_values: &[ValueId],
|
||||
) -> Result<Option<ValueId>, String> {
|
||||
if let Some(cands) = self.static_method_index.get(name) {
|
||||
if let Some(cands) = self.comp_ctx.static_method_index.get(name) {
|
||||
let mut matches: Vec<(String, usize)> = cands
|
||||
.iter()
|
||||
.cloned()
|
||||
|
||||
@ -26,16 +26,16 @@ impl MirBuilder {
|
||||
/// 🎯 箱理論: Step 1 - Lowering Context準備
|
||||
fn prepare_lowering_context(&mut self, func_name: &str) -> LoweringContext {
|
||||
// Static box context設定
|
||||
let saved_static_ctx = self.current_static_box.clone();
|
||||
let saved_static_ctx = self.comp_ctx.current_static_box.clone();
|
||||
if let Some(pos) = func_name.find('.') {
|
||||
let box_name = &func_name[..pos];
|
||||
if !box_name.is_empty() {
|
||||
self.current_static_box = Some(box_name.to_string());
|
||||
self.comp_ctx.current_static_box = Some(box_name.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// BoxCompilationContext vs saved_var_map モード判定
|
||||
let context_active = self.compilation_context.is_some();
|
||||
let context_active = self.comp_ctx.compilation_context.is_some();
|
||||
let saved_var_map = if !context_active {
|
||||
Some(std::mem::take(&mut self.variable_ctx.variable_map))
|
||||
} else {
|
||||
@ -43,7 +43,7 @@ impl MirBuilder {
|
||||
};
|
||||
|
||||
// 関数スコープ SlotRegistry は元の関数側から退避しておくよ。
|
||||
let saved_slot_registry = self.current_slot_registry.take();
|
||||
let saved_slot_registry = self.comp_ctx.current_slot_registry.take();
|
||||
|
||||
// BoxCompilationContext mode: clear()で完全独立化
|
||||
if context_active {
|
||||
@ -93,7 +93,7 @@ impl MirBuilder {
|
||||
self.scope_ctx.current_function = Some(function);
|
||||
self.current_block = Some(entry);
|
||||
// 新しい関数スコープ用の SlotRegistry を準備するよ(観測専用)
|
||||
self.current_slot_registry = Some(FunctionSlotRegistry::new());
|
||||
self.comp_ctx.current_slot_registry = Some(FunctionSlotRegistry::new());
|
||||
self.ensure_block_exists(entry)?;
|
||||
|
||||
// Region 観測レイヤ: static 関数用の FunctionRegion を積むよ。
|
||||
@ -157,7 +157,7 @@ impl MirBuilder {
|
||||
self.register_value_kind(pid, MirValueKind::Parameter(param_idx));
|
||||
}
|
||||
|
||||
if let Some(reg) = self.current_slot_registry.as_mut() {
|
||||
if let Some(reg) = self.comp_ctx.current_slot_registry.as_mut() {
|
||||
for (name, ty) in slot_regs {
|
||||
reg.ensure_slot(&name, ty);
|
||||
}
|
||||
@ -247,9 +247,9 @@ impl MirBuilder {
|
||||
}
|
||||
|
||||
// Static box context復元
|
||||
self.current_static_box = ctx.saved_static_ctx;
|
||||
self.comp_ctx.current_static_box = ctx.saved_static_ctx;
|
||||
// 関数スコープ SlotRegistry も元の関数に戻すよ。
|
||||
self.current_slot_registry = ctx.saved_slot_registry;
|
||||
self.comp_ctx.current_slot_registry = ctx.saved_slot_registry;
|
||||
}
|
||||
|
||||
/// 🎯 箱理論: Step 2b - 関数スケルトン作成(instance method版)
|
||||
@ -274,7 +274,7 @@ impl MirBuilder {
|
||||
self.scope_ctx.current_function = Some(function);
|
||||
self.current_block = Some(entry);
|
||||
// instance method 用の関数スコープ SlotRegistry もここで用意するよ。
|
||||
self.current_slot_registry = Some(FunctionSlotRegistry::new());
|
||||
self.comp_ctx.current_slot_registry = Some(FunctionSlotRegistry::new());
|
||||
self.ensure_block_exists(entry)?;
|
||||
|
||||
// Region 観測レイヤ: instance method 用の FunctionRegion も積んでおくよ。
|
||||
@ -328,7 +328,7 @@ impl MirBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(reg) = self.current_slot_registry.as_mut() {
|
||||
if let Some(reg) = self.comp_ctx.current_slot_registry.as_mut() {
|
||||
for (name, ty) in slot_regs {
|
||||
reg.ensure_slot(&name, ty);
|
||||
}
|
||||
@ -354,7 +354,7 @@ impl MirBuilder {
|
||||
body.len(),
|
||||
func_name
|
||||
);
|
||||
self.fn_body_ast = Some(body.clone());
|
||||
self.comp_ctx.fn_body_ast = Some(body.clone());
|
||||
|
||||
// Step 1: Context準備
|
||||
let mut ctx = self.prepare_lowering_context(&func_name);
|
||||
@ -383,7 +383,7 @@ impl MirBuilder {
|
||||
self.restore_lowering_context(ctx);
|
||||
|
||||
// Phase 200-C: Clear fn_body_ast after function lowering
|
||||
self.fn_body_ast = None;
|
||||
self.comp_ctx.fn_body_ast = None;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -397,7 +397,7 @@ impl MirBuilder {
|
||||
body: Vec<ASTNode>,
|
||||
) -> Result<(), String> {
|
||||
// Phase 200-C: Store fn_body for capture analysis
|
||||
self.fn_body_ast = Some(body.clone());
|
||||
self.comp_ctx.fn_body_ast = Some(body.clone());
|
||||
|
||||
// Step 1: Context準備(instance methodでは不要だがAPI統一のため)
|
||||
let mut ctx = LoweringContext {
|
||||
@ -406,7 +406,7 @@ impl MirBuilder {
|
||||
saved_static_ctx: None,
|
||||
saved_function: None,
|
||||
saved_block: None,
|
||||
saved_slot_registry: self.current_slot_registry.take(),
|
||||
saved_slot_registry: self.comp_ctx.current_slot_registry.take(),
|
||||
};
|
||||
|
||||
// Step 2b: 関数スケルトン作成(method版)
|
||||
@ -475,10 +475,10 @@ impl MirBuilder {
|
||||
if let Some(saved) = ctx.saved_var_map {
|
||||
self.variable_ctx.variable_map = saved;
|
||||
}
|
||||
self.current_slot_registry = ctx.saved_slot_registry;
|
||||
self.comp_ctx.current_slot_registry = ctx.saved_slot_registry;
|
||||
|
||||
// Phase 200-C: Clear fn_body_ast after function lowering
|
||||
self.fn_body_ast = None;
|
||||
self.comp_ctx.fn_body_ast = None;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ impl CallMaterializerBox {
|
||||
}
|
||||
|
||||
// 2) Unique static-method fallback: name+arity → Box.name/Arity
|
||||
if let Some(cands) = builder.static_method_index.get(name) {
|
||||
if let Some(cands) = builder.comp_ctx.static_method_index.get(name) {
|
||||
let mut matches: Vec<(String, usize)> = cands
|
||||
.iter()
|
||||
.cloned()
|
||||
|
||||
@ -154,7 +154,7 @@ impl UnifiedCallEmitterBox {
|
||||
let resolver = super::resolver::CalleeResolverBox::new(
|
||||
&builder.type_ctx.value_origin_newbox,
|
||||
&builder.type_ctx.value_types,
|
||||
Some(&builder.type_registry), // 🎯 TypeRegistry を渡す
|
||||
Some(&builder.comp_ctx.type_registry), // 🎯 TypeRegistry を渡す
|
||||
);
|
||||
let mut callee = match resolver.resolve(target.clone()) {
|
||||
Ok(c) => c,
|
||||
@ -279,7 +279,7 @@ impl UnifiedCallEmitterBox {
|
||||
let resolver = super::resolver::CalleeResolverBox::new(
|
||||
&builder.type_ctx.value_origin_newbox,
|
||||
&builder.type_ctx.value_types,
|
||||
Some(&builder.type_registry),
|
||||
Some(&builder.comp_ctx.type_registry),
|
||||
);
|
||||
resolver.validate_args(&callee, &args)?;
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ impl MirBuilder {
|
||||
) -> Result<crate::mir::definitions::call_unified::Callee, String> {
|
||||
super::method_resolution::resolve_call_target(
|
||||
name,
|
||||
&self.current_static_box,
|
||||
&self.comp_ctx.current_static_box,
|
||||
&self.variable_ctx.variable_map,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user