refactor(mir): Remove ScopeContext legacy fields (Phase 2-4/7)
完全移行→削除の安全順序(Option C)に従い、ScopeContextの
deprecated フィールドと sync helpers を完全削除。
## Changes
- Migrated all access sites to scope_ctx.*
- Removed 7 deprecated fields:
- current_function
- lexical_scope_stack
- function_param_names
- loop_header_stack
- loop_exit_stack
- if_merge_stack
- debug_scope_stack
- Removed 2 sync helpers (sync_scope_ctx_to_legacy, sync_legacy_to_scope_ctx)
- Updated 20+ files with direct field access
## Tests
- cargo build --release: PASS ✅
- Deprecation warnings: 255 → 166 (-89, -35%)
Phase 2 Progress: 4/7 contexts complete (57%)
This commit is contained in:
@ -26,7 +26,7 @@ pub(super) fn build_exit_phi(
|
||||
) -> Result<(Option<ValueId>, BTreeMap<String, ValueId>), String> {
|
||||
let mut carrier_phis: BTreeMap<String, ValueId> = BTreeMap::new();
|
||||
|
||||
let exit_phi_result_id = if let Some(ref mut func) = builder.current_function {
|
||||
let exit_phi_result_id = if let Some(ref mut func) = builder.scope_ctx.current_function {
|
||||
let mut exit_block = BasicBlock::new(exit_block_id);
|
||||
|
||||
// Phase 189-Fix: If we collected return values, create a PHI in exit block
|
||||
|
||||
@ -149,7 +149,7 @@ pub(super) fn merge_and_rewrite(
|
||||
|
||||
// Phase 195 FIX: Reuse existing block if present (preserves PHI from JoinIR Select lowering)
|
||||
// ultrathink "finalizer集約案": Don't overwrite blocks with BasicBlock::new()
|
||||
let mut new_block = if let Some(ref mut current_func) = builder.current_function {
|
||||
let mut new_block = if let Some(ref mut current_func) = builder.scope_ctx.current_function {
|
||||
current_func
|
||||
.blocks
|
||||
.remove(&new_block_id)
|
||||
@ -811,7 +811,7 @@ pub(super) fn merge_and_rewrite(
|
||||
}
|
||||
|
||||
// Add block to current function
|
||||
if let Some(ref mut current_func) = builder.current_function {
|
||||
if let Some(ref mut current_func) = builder.scope_ctx.current_function {
|
||||
current_func.add_block(new_block);
|
||||
}
|
||||
}
|
||||
@ -866,7 +866,7 @@ pub(super) fn merge_and_rewrite(
|
||||
|
||||
// Use BoundaryInjector to inject Copy instructions
|
||||
// Phase 177-3 Option B: Returns reallocations map for condition_bindings with PHI collisions
|
||||
if let Some(ref mut current_func) = builder.current_function {
|
||||
if let Some(ref mut current_func) = builder.scope_ctx.current_function {
|
||||
let _reallocations = BoundaryInjector::inject_boundary_copies(
|
||||
current_func,
|
||||
entry_block_remapped,
|
||||
|
||||
@ -733,7 +733,7 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
if let Some(boundary) = boundary {
|
||||
if let Some(ref func) = builder.current_function {
|
||||
if let Some(ref func) = builder.scope_ctx.current_function {
|
||||
verify_joinir_contracts(
|
||||
func,
|
||||
entry_block,
|
||||
|
||||
@ -115,7 +115,7 @@ impl super::MirBuilder {
|
||||
"Loop lowering failed: JoinIR does not support this pattern, and LoopBuilder has been removed.\n\
|
||||
Function: {}\n\
|
||||
Hint: This loop pattern is not supported. All loops must use JoinIR lowering.",
|
||||
self.current_function.as_ref().map(|f| f.signature.name.as_str()).unwrap_or("<unknown>")
|
||||
self.scope_ctx.current_function.as_ref().map(|f| f.signature.name.as_str()).unwrap_or("<unknown>")
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user