Files
hakorune/src/mir/builder/origin/phi.rs
nyash-codex b92f85f993 refactor(mir): Remove TypeContext legacy fields (Phase 2-3/7)
完全移行→削除の安全順序(Option C)に従い、TypeContext の
deprecated フィールドと sync helpers を完全削除。

⚠️ 危険ゾーン: TypeFactsBox 等の同名フィールドと混同しないよう、
ファイル単位で手作業移行を実施。

## Changes
- Migrated all MirBuilder access sites to type_ctx.* (manual, 40+ files)
- Removed 3 deprecated fields (value_types, value_kinds, value_origin_newbox)
- Removed 2 sync helpers (sync_type_ctx_to_legacy, sync_legacy_to_type_ctx)
- Verified TypeFactsBox, CalleeGuardBox unchanged (no false positives)

## Tests
- cargo test --release --lib: 1029/1033 PASS
- TypeFactsBox integration: PASS (borrowed references unchanged)
- Deprecation warnings: 456 → 255 (-201, -44%)

## Safety Verification
 TypeFactsBox unchanged (still uses &'a BTreeMap borrowed references)
 CalleeGuardBox unchanged
 CalleeResolverBox unchanged
 BoxCompilationContext unchanged

Phase 2 Progress: 3/7 contexts complete (43%)
-  MetadataContext
-  CoreContext
-  TypeContext (this commit)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-15 23:27:24 +09:00

59 lines
1.8 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use super::super::{BasicBlockId, MirBuilder, MirType, ValueId};
/// Lightweight propagation at PHI when all inputs agree型/起源)。
/// 仕様は不変: 一致時のみ dst にコピーする(不一致/未知は何もしない)。
pub(crate) fn propagate_phi_meta(
builder: &mut MirBuilder,
dst: ValueId,
inputs: &Vec<(BasicBlockId, ValueId)>,
) {
// Type一致のときだけコピー
let mut common_ty: Option<MirType> = None;
let mut ty_agree = true;
for (_bb, v) in inputs.iter() {
if let Some(t) = builder.type_ctx.value_types.get(v).cloned() {
match &common_ty {
None => common_ty = Some(t),
Some(ct) => {
if ct != &t {
ty_agree = false;
break;
}
}
}
} else {
ty_agree = false;
break;
}
}
if ty_agree {
if let Some(ct) = common_ty {
builder.type_ctx.value_types.insert(dst, ct);
}
}
// Origin一致のときだけコピー
let mut common_cls: Option<String> = None;
let mut cls_agree = true;
for (_bb, v) in inputs.iter() {
if let Some(c) = builder.type_ctx.value_origin_newbox.get(v).cloned() {
match &common_cls {
None => common_cls = Some(c),
Some(cc) => {
if cc != &c {
cls_agree = false;
break;
}
}
}
} else {
cls_agree = false;
break;
}
}
if cls_agree {
if let Some(cc) = common_cls {
builder.type_ctx.value_origin_newbox.insert(dst, cc);
}
}
}