完全移行→削除の安全順序(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%)
34 lines
1.0 KiB
Rust
34 lines
1.0 KiB
Rust
//! BranchEmissionBox — 分岐/ジャンプ命令発行の薄いヘルパ(仕様不変)
|
|
|
|
use crate::mir::builder::MirBuilder;
|
|
use crate::mir::{BasicBlockId, MirInstruction};
|
|
|
|
#[inline]
|
|
pub fn emit_conditional(
|
|
b: &mut MirBuilder,
|
|
cond: crate::mir::ValueId,
|
|
then_bb: BasicBlockId,
|
|
else_bb: BasicBlockId,
|
|
) -> Result<(), String> {
|
|
if let (Some(func), Some(cur_bb)) = (b.scope_ctx.current_function.as_mut(), b.current_block) {
|
|
crate::mir::ssot::cf_common::set_branch(func, cur_bb, cond, then_bb, else_bb);
|
|
Ok(())
|
|
} else {
|
|
b.emit_instruction(MirInstruction::Branch {
|
|
condition: cond,
|
|
then_bb,
|
|
else_bb,
|
|
})
|
|
}
|
|
}
|
|
|
|
#[inline]
|
|
pub fn emit_jump(b: &mut MirBuilder, target: BasicBlockId) -> Result<(), String> {
|
|
if let (Some(func), Some(cur_bb)) = (b.scope_ctx.current_function.as_mut(), b.current_block) {
|
|
crate::mir::ssot::cf_common::set_jump(func, cur_bb, target);
|
|
Ok(())
|
|
} else {
|
|
b.emit_instruction(MirInstruction::Jump { target })
|
|
}
|
|
}
|