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,
|
||||
)
|
||||
}
|
||||
|
||||
@ -295,11 +295,11 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
|
||||
// Phase 201-A: Set reserved IDs in MirBuilder so next_value_id() skips them
|
||||
// This protects against carrier corruption when break conditions emit Const instructions
|
||||
builder.reserved_value_ids = reserved_phi_dsts.clone();
|
||||
if debug && !builder.reserved_value_ids.is_empty() {
|
||||
builder.comp_ctx.reserved_value_ids = reserved_phi_dsts.clone();
|
||||
if debug && !builder.comp_ctx.reserved_value_ids.is_empty() {
|
||||
eprintln!(
|
||||
"[cf_loop/joinir] Phase 201-A: Set builder.reserved_value_ids = {:?}",
|
||||
builder.reserved_value_ids
|
||||
"[cf_loop/joinir] Phase 201-A: Set builder.comp_ctx.reserved_value_ids = {:?}",
|
||||
builder.comp_ctx.reserved_value_ids
|
||||
);
|
||||
}
|
||||
|
||||
@ -750,14 +750,14 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
|
||||
// Phase 201-A: Clear reserved ValueIds after merge completes
|
||||
// Future loops will set their own reserved IDs
|
||||
if !builder.reserved_value_ids.is_empty() {
|
||||
if !builder.comp_ctx.reserved_value_ids.is_empty() {
|
||||
if debug {
|
||||
eprintln!(
|
||||
"[cf_loop/joinir] Phase 201-A: Clearing reserved_value_ids (was {:?})",
|
||||
builder.reserved_value_ids
|
||||
builder.comp_ctx.reserved_value_ids
|
||||
);
|
||||
}
|
||||
builder.reserved_value_ids.clear();
|
||||
builder.comp_ctx.reserved_value_ids.clear();
|
||||
}
|
||||
|
||||
// Phase 246-EX-FIX: Handle loop variable expr_result separately from carrier expr_result
|
||||
|
||||
@ -127,7 +127,7 @@ impl MirBuilder {
|
||||
|
||||
// Phase 200-C: Pass fn_body_ast to LoopPatternContext if available
|
||||
// Clone fn_body_ast to avoid borrow checker issues
|
||||
let fn_body_clone = self.fn_body_ast.clone();
|
||||
let fn_body_clone = self.comp_ctx.fn_body_ast.clone();
|
||||
trace::trace().routing(
|
||||
"router",
|
||||
func_name,
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -207,7 +207,7 @@ impl super::MirBuilder {
|
||||
// Generic static box: lower all static methods into standalone MIR functions (BoxName.method/N)
|
||||
// Note: Metadata clearing is now handled by BoxCompilationContext (箱理論)
|
||||
// See lifecycle.rs for context creation and builder_calls.rs for context swap
|
||||
self.user_defined_boxes.insert(name.clone());
|
||||
self.comp_ctx.user_defined_boxes.insert(name.clone());
|
||||
for (method_name, method_ast) in methods.clone() {
|
||||
if let ASTNode::FunctionDeclaration { params, body, .. } = method_ast {
|
||||
let func_name = format!(
|
||||
@ -222,7 +222,7 @@ impl super::MirBuilder {
|
||||
body.clone(),
|
||||
)?;
|
||||
// Index static method for fallback resolution of bare calls
|
||||
self.static_method_index
|
||||
self.comp_ctx.static_method_index
|
||||
.entry(method_name.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.push((name.clone(), params.len()));
|
||||
@ -234,7 +234,7 @@ impl super::MirBuilder {
|
||||
}
|
||||
} else {
|
||||
// Instance box: register type and lower instance methods/ctors as functions
|
||||
self.user_defined_boxes.insert(name.clone());
|
||||
self.comp_ctx.user_defined_boxes.insert(name.clone());
|
||||
self.build_box_declaration(
|
||||
name.clone(),
|
||||
methods.clone(),
|
||||
@ -311,9 +311,9 @@ impl super::MirBuilder {
|
||||
self.type_ctx.value_types
|
||||
.insert(arr_id, super::MirType::Box("ArrayBox".to_string()));
|
||||
// TypeRegistry + trace for deterministic debug
|
||||
self.type_registry
|
||||
self.comp_ctx.type_registry
|
||||
.record_newbox(arr_id, "ArrayBox".to_string());
|
||||
self.type_registry
|
||||
self.comp_ctx.type_registry
|
||||
.record_type(arr_id, super::MirType::Box("ArrayBox".to_string()));
|
||||
type_trace::origin("newbox:ArrayLiteral", arr_id, "ArrayBox");
|
||||
type_trace::ty(
|
||||
@ -354,9 +354,9 @@ impl super::MirBuilder {
|
||||
.insert(map_id, "MapBox".to_string());
|
||||
self.type_ctx.value_types
|
||||
.insert(map_id, super::MirType::Box("MapBox".to_string()));
|
||||
self.type_registry
|
||||
self.comp_ctx.type_registry
|
||||
.record_newbox(map_id, "MapBox".to_string());
|
||||
self.type_registry
|
||||
self.comp_ctx.type_registry
|
||||
.record_type(map_id, super::MirType::Box("MapBox".to_string()));
|
||||
type_trace::origin("newbox:MapLiteral", map_id, "MapBox");
|
||||
type_trace::ty(
|
||||
|
||||
@ -17,7 +17,7 @@ impl super::MirBuilder {
|
||||
// Unified members: if object class is known and has a synthetic getter for `field`,
|
||||
// rewrite to method call `__get_<field>()`.
|
||||
if let Some(class_name) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
|
||||
if let Some(map) = self.property_getters_by_box.get(&class_name) {
|
||||
if let Some(map) = self.comp_ctx.property_getters_by_box.get(&class_name) {
|
||||
if let Some(kind) = map.get(&field) {
|
||||
let mname = match kind {
|
||||
super::PropertyKind::Computed => format!("__get_{}", field),
|
||||
@ -53,7 +53,7 @@ impl super::MirBuilder {
|
||||
|
||||
// Propagate recorded origin class for this field if any (ValueId-scoped)
|
||||
if let Some(class_name) = self
|
||||
.field_origin_class
|
||||
.comp_ctx.field_origin_class
|
||||
.get(&(object_value, field.clone()))
|
||||
.cloned()
|
||||
{
|
||||
@ -61,7 +61,7 @@ impl super::MirBuilder {
|
||||
} else if let Some(base_cls) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
|
||||
// Cross-function heuristic: use class-level field origin mapping
|
||||
if let Some(fcls) = self
|
||||
.field_origin_by_box
|
||||
.comp_ctx.field_origin_by_box
|
||||
.get(&(base_cls.clone(), field.clone()))
|
||||
.cloned()
|
||||
{
|
||||
@ -89,7 +89,7 @@ impl super::MirBuilder {
|
||||
{
|
||||
if let Ok(base_id) = self.build_expression(*inner_obj.clone()) {
|
||||
if let Some(cls) = self
|
||||
.field_origin_class
|
||||
.comp_ctx.field_origin_class
|
||||
.get(&(base_id, inner_field))
|
||||
.cloned()
|
||||
{
|
||||
@ -99,7 +99,7 @@ impl super::MirBuilder {
|
||||
}
|
||||
}
|
||||
if let Some(class_name) = inferred_class {
|
||||
if let Some(weak_set) = self.weak_fields_by_box.get(&class_name) {
|
||||
if let Some(weak_set) = self.comp_ctx.weak_fields_by_box.get(&class_name) {
|
||||
if weak_set.contains(&field) {
|
||||
let loaded = self.emit_weak_load(field_val)?;
|
||||
let _ = self.emit_barrier_read(loaded);
|
||||
@ -129,7 +129,7 @@ impl super::MirBuilder {
|
||||
|
||||
// If base is known and field is weak, create WeakRef before store
|
||||
if let Some(class_name) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
|
||||
if let Some(weak_set) = self.weak_fields_by_box.get(&class_name) {
|
||||
if let Some(weak_set) = self.comp_ctx.weak_fields_by_box.get(&class_name) {
|
||||
if weak_set.contains(&field) {
|
||||
value_result = self.emit_weak_new(value_result)?;
|
||||
}
|
||||
@ -159,7 +159,7 @@ impl super::MirBuilder {
|
||||
|
||||
// Write barrier if weak field
|
||||
if let Some(class_name) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
|
||||
if let Some(weak_set) = self.weak_fields_by_box.get(&class_name) {
|
||||
if let Some(weak_set) = self.comp_ctx.weak_fields_by_box.get(&class_name) {
|
||||
if weak_set.contains(&field) {
|
||||
let _ = self.emit_barrier_write(value_result);
|
||||
}
|
||||
@ -168,11 +168,11 @@ impl super::MirBuilder {
|
||||
|
||||
// Record origin class for this field value if known
|
||||
if let Some(val_cls) = self.type_ctx.value_origin_newbox.get(&value_result).cloned() {
|
||||
self.field_origin_class
|
||||
self.comp_ctx.field_origin_class
|
||||
.insert((object_value, field.clone()), val_cls.clone());
|
||||
// Also record class-level mapping if base object class is known
|
||||
if let Some(base_cls) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
|
||||
self.field_origin_by_box
|
||||
self.comp_ctx.field_origin_by_box
|
||||
.insert((base_cls, field.clone()), val_cls);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,11 +88,11 @@ impl super::MirBuilder {
|
||||
..
|
||||
} => {
|
||||
if !*is_static {
|
||||
self.user_defined_boxes.insert(name.clone());
|
||||
self.comp_ctx.user_defined_boxes.insert(name.clone());
|
||||
} else {
|
||||
for (mname, mast) in methods {
|
||||
if let ASTNode::FunctionDeclaration { params, .. } = mast {
|
||||
self.static_method_index
|
||||
self.comp_ctx.static_method_index
|
||||
.entry(mname.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.push((name.clone(), params.len()));
|
||||
@ -124,7 +124,7 @@ impl super::MirBuilder {
|
||||
|
||||
// 関数スコープの SlotRegistry を初期化するよ(観測専用)。
|
||||
// main 関数用のスロット登録箱として使う想定だよ。
|
||||
self.current_slot_registry =
|
||||
self.comp_ctx.current_slot_registry =
|
||||
Some(crate::mir::region::function_slot_registry::FunctionSlotRegistry::new());
|
||||
|
||||
// Region 観測レイヤ: main 関数の FunctionRegion を 1 つ作っておくよ。
|
||||
@ -189,7 +189,7 @@ impl super::MirBuilder {
|
||||
// スコープを抜けると自動的にコンテキストが破棄される
|
||||
{
|
||||
let ctx = super::context::BoxCompilationContext::new();
|
||||
self.compilation_context = Some(ctx);
|
||||
self.comp_ctx.compilation_context = Some(ctx);
|
||||
|
||||
// Lower all static methods into standalone functions: BoxName.method/Arity
|
||||
for (mname, mast) in methods.iter() {
|
||||
@ -207,7 +207,7 @@ impl super::MirBuilder {
|
||||
params.clone(),
|
||||
body.clone(),
|
||||
)?;
|
||||
self.static_method_index
|
||||
self.comp_ctx.static_method_index
|
||||
.entry(mname.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.push((name.clone(), params.len()));
|
||||
@ -217,12 +217,12 @@ impl super::MirBuilder {
|
||||
|
||||
// 🎯 箱理論: コンテキストをクリア(スコープ終了で自動破棄)
|
||||
// これにより、次のstatic boxは汚染されていない状態から開始される
|
||||
self.compilation_context = None;
|
||||
self.comp_ctx.compilation_context = None;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Instance box: register type and lower instance methods/ctors as functions
|
||||
self.user_defined_boxes.insert(name.clone());
|
||||
self.comp_ctx.user_defined_boxes.insert(name.clone());
|
||||
self.build_box_declaration(
|
||||
name.clone(),
|
||||
methods.clone(),
|
||||
@ -602,7 +602,7 @@ impl super::MirBuilder {
|
||||
crate::mir::region::observer::pop_function_region(self);
|
||||
|
||||
// main 関数スコープの SlotRegistry を解放するよ。
|
||||
self.current_slot_registry = None;
|
||||
self.comp_ctx.current_slot_registry = None;
|
||||
|
||||
Ok(module)
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ pub fn propagate(builder: &mut MirBuilder, src: ValueId, dst: ValueId) {
|
||||
|
||||
if use_registry {
|
||||
// 🎯 新: TypeRegistry 経由(トレース可能)
|
||||
builder.type_registry.propagate(src, dst);
|
||||
builder.comp_ctx.type_registry.propagate(src, dst);
|
||||
} else {
|
||||
// 従来: 直接アクセス(後方互換性)
|
||||
if let Some(t) = builder.type_ctx.value_types.get(&src).cloned() {
|
||||
@ -40,7 +40,7 @@ pub fn propagate_with_override(builder: &mut MirBuilder, dst: ValueId, ty: MirTy
|
||||
let ty_clone = ty.clone();
|
||||
if use_registry {
|
||||
// 🎯 新: TypeRegistry 経由
|
||||
builder.type_registry.record_type(dst, ty);
|
||||
builder.comp_ctx.type_registry.record_type(dst, ty);
|
||||
} else {
|
||||
// 従来: 直接アクセス
|
||||
builder.type_ctx.value_types.insert(dst, ty);
|
||||
|
||||
@ -6,7 +6,7 @@ use super::super::{MirBuilder, MirType, ValueId};
|
||||
/// - それ以外: 付与せず(挙動不変)
|
||||
pub(crate) fn annotate_me_origin(builder: &mut MirBuilder, me_id: ValueId) {
|
||||
let mut cls: Option<String> = None;
|
||||
if let Some(c) = builder.current_static_box.clone() {
|
||||
if let Some(c) = builder.comp_ctx.current_static_box.clone() {
|
||||
if !c.is_empty() {
|
||||
cls = Some(c);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ pub(crate) fn try_known_rewrite(
|
||||
return None;
|
||||
}
|
||||
// Only user-defined boxes (plugin/core boxesは対象外)
|
||||
if !builder.user_defined_boxes.contains(cls) {
|
||||
if !builder.comp_ctx.user_defined_boxes.contains(cls) {
|
||||
return None;
|
||||
}
|
||||
// Policy gates(従来互換)
|
||||
@ -110,7 +110,7 @@ pub(crate) fn try_known_rewrite_to_dst(
|
||||
if builder.type_ctx.value_origin_newbox.get(&object_value).is_none() {
|
||||
return None;
|
||||
}
|
||||
if !builder.user_defined_boxes.contains(cls) {
|
||||
if !builder.comp_ctx.user_defined_boxes.contains(cls) {
|
||||
return None;
|
||||
}
|
||||
let allow_userbox_rewrite =
|
||||
@ -181,7 +181,7 @@ pub(crate) fn try_unique_suffix_rewrite(
|
||||
let fname = cands.remove(0);
|
||||
// 🎯 Phase 21.7++ Phase 3: StaticMethodId SSOT 実装
|
||||
let id = crate::mir::naming::StaticMethodId::parse(&fname)?;
|
||||
if !builder.user_defined_boxes.contains(&id.box_name) {
|
||||
if !builder.comp_ctx.user_defined_boxes.contains(&id.box_name) {
|
||||
return None;
|
||||
}
|
||||
// unified
|
||||
@ -232,7 +232,7 @@ pub(crate) fn try_unique_suffix_rewrite_to_dst(
|
||||
let fname = cands.remove(0);
|
||||
// 🎯 Phase 21.7++ Phase 3: StaticMethodId SSOT 実装
|
||||
let id = crate::mir::naming::StaticMethodId::parse(&fname)?;
|
||||
if !builder.user_defined_boxes.contains(&id.box_name) {
|
||||
if !builder.comp_ctx.user_defined_boxes.contains(&id.box_name) {
|
||||
return None;
|
||||
}
|
||||
let _name_const = match crate::mir::builder::name_const::make_name_const_result(builder, &fname)
|
||||
|
||||
@ -340,7 +340,7 @@ impl super::MirBuilder {
|
||||
}
|
||||
self.declare_local_in_current_scope(var_name, var_id)?;
|
||||
// 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(&var_id).cloned();
|
||||
reg.ensure_slot(&var_name, ty);
|
||||
}
|
||||
@ -430,7 +430,7 @@ impl super::MirBuilder {
|
||||
self.type_ctx.value_types
|
||||
.insert(future_id, MirType::Future(Box::new(MirType::Unknown)));
|
||||
self.variable_ctx.variable_map.insert(variable.clone(), future_id);
|
||||
if let Some(reg) = self.current_slot_registry.as_mut() {
|
||||
if let Some(reg) = self.comp_ctx.current_slot_registry.as_mut() {
|
||||
reg.ensure_slot(&variable, None);
|
||||
}
|
||||
return Ok(future_id);
|
||||
@ -449,7 +449,7 @@ impl super::MirBuilder {
|
||||
self.type_ctx.value_types
|
||||
.insert(future_id, MirType::Future(Box::new(inner)));
|
||||
self.variable_ctx.variable_map.insert(variable.clone(), future_id);
|
||||
if let Some(reg) = self.current_slot_registry.as_mut() {
|
||||
if let Some(reg) = self.comp_ctx.current_slot_registry.as_mut() {
|
||||
reg.ensure_slot(&variable, None);
|
||||
}
|
||||
Ok(future_id)
|
||||
@ -481,14 +481,14 @@ impl super::MirBuilder {
|
||||
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 {
|
||||
let me_tag = if let Some(ref cls) = self.comp_ctx.current_static_box {
|
||||
cls.clone()
|
||||
} else {
|
||||
"__me__".to_string()
|
||||
};
|
||||
let me_value = crate::mir::builder::emission::constant::emit_string(self, me_tag);
|
||||
self.variable_ctx.variable_map.insert("me".to_string(), me_value);
|
||||
if let Some(reg) = self.current_slot_registry.as_mut() {
|
||||
if let Some(reg) = self.comp_ctx.current_slot_registry.as_mut() {
|
||||
reg.ensure_slot("me", None);
|
||||
}
|
||||
// P0: Known 化 — 分かる範囲で me の起源クラスを付与(挙動不変)。
|
||||
|
||||
@ -46,7 +46,7 @@ impl super::MirBuilder {
|
||||
};
|
||||
|
||||
// Phase 201-A: Skip reserved PHI dst ValueIds
|
||||
if !self.reserved_value_ids.contains(&candidate) {
|
||||
if !self.comp_ctx.reserved_value_ids.contains(&candidate) {
|
||||
return candidate;
|
||||
}
|
||||
// Reserved ID - try next one (loop continues)
|
||||
@ -327,7 +327,7 @@ impl super::MirBuilder {
|
||||
}
|
||||
}
|
||||
if let Some(bt) = recv_box {
|
||||
if let Some(mt) = self.plugin_method_sigs.get(&(bt.clone(), method.clone())) {
|
||||
if let Some(mt) = self.comp_ctx.plugin_method_sigs.get(&(bt.clone(), method.clone())) {
|
||||
self.type_ctx.value_types.insert(d, mt.clone());
|
||||
} else {
|
||||
// Phase 84-4-B: ビルトイン Box のメソッド戻り値型推論
|
||||
|
||||
Reference in New Issue
Block a user