Files
hakorune/src/mir/builder/origin/infer.rs
nyash-codex e404746612 refactor(mir): Phase 139-P3-B - RoutingDecision を enum 対応 + レガシー削除
- RoutingDecision の missing_caps を Vec<CapabilityTag> に変更(型安全化)
- error_tags は to_tag() メソッドで自動生成
- 全 callsite を enum variant に修正
- capability_tags モジュール(文字列定数群)を完全削除
- 全テスト PASS(型安全性向上を確認)
- フォーマット適用
2025-12-16 07:02:14 +09:00

33 lines
1.2 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::{MirBuilder, MirType, ValueId};
/// Annotate the origin of `me`/receiver with a Known class when分かる範囲のみ。
/// - 優先: current_static_box静的ボックスの文脈
/// - 次点: 現在の関数名のプレフィックス("Class.method/Arity"
/// - それ以外: 付与せず(挙動不変)
pub(crate) fn annotate_me_origin(builder: &mut MirBuilder, me_id: ValueId) {
let mut cls: Option<String> = None;
if let Some(c) = builder.comp_ctx.current_static_box.clone() {
if !c.is_empty() {
cls = Some(c);
}
}
if cls.is_none() {
if let Some(ref fun) = builder.scope_ctx.current_function {
if let Some(dot) = fun.signature.name.find('.') {
let c = fun.signature.name[..dot].to_string();
if !c.is_empty() {
cls = Some(c);
}
}
}
}
if let Some(c) = cls {
// Record both origin class and a Box type hint for downstream passes観測用
builder
.type_ctx
.value_origin_newbox
.insert(me_id, c.clone());
builder.type_ctx.value_types.insert(me_id, MirType::Box(c));
}
}