- RoutingDecision の missing_caps を Vec<CapabilityTag> に変更(型安全化) - error_tags は to_tag() メソッドで自動生成 - 全 callsite を enum variant に修正 - capability_tags モジュール(文字列定数群)を完全削除 - 全テスト PASS(型安全性向上を確認) - フォーマット適用
97 lines
2.7 KiB
Rust
97 lines
2.7 KiB
Rust
//! ConstantEmissionBox — Const 命令の発行を集約(仕様不変)
|
|
//!
|
|
//! ✅ Phase 25.1b Fix: All constant emission now uses function-local ID generator
|
|
//! when inside a function context to ensure proper SSA verification.
|
|
|
|
use crate::mir::builder::MirBuilder;
|
|
use crate::mir::{ConstValue, MirInstruction, ValueId};
|
|
|
|
#[inline]
|
|
pub fn emit_integer(b: &mut MirBuilder, val: i64) -> ValueId {
|
|
let dst = b.next_value_id();
|
|
let _ = b.emit_instruction(MirInstruction::Const {
|
|
dst,
|
|
value: ConstValue::Integer(val),
|
|
});
|
|
// Phase 84-1: Integer constant type annotation
|
|
b.type_ctx
|
|
.value_types
|
|
.insert(dst, crate::mir::MirType::Integer);
|
|
dst
|
|
}
|
|
|
|
#[inline]
|
|
pub fn emit_bool(b: &mut MirBuilder, val: bool) -> ValueId {
|
|
let dst = b.next_value_id();
|
|
let _ = b.emit_instruction(MirInstruction::Const {
|
|
dst,
|
|
value: ConstValue::Bool(val),
|
|
});
|
|
// Phase 84-1: Bool constant type annotation
|
|
b.type_ctx
|
|
.value_types
|
|
.insert(dst, crate::mir::MirType::Bool);
|
|
dst
|
|
}
|
|
|
|
#[inline]
|
|
pub fn emit_float(b: &mut MirBuilder, val: f64) -> ValueId {
|
|
let dst = b.next_value_id();
|
|
let _ = b.emit_instruction(MirInstruction::Const {
|
|
dst,
|
|
value: ConstValue::Float(val),
|
|
});
|
|
// Phase 84-1: Float constant type annotation
|
|
b.type_ctx
|
|
.value_types
|
|
.insert(dst, crate::mir::MirType::Float);
|
|
dst
|
|
}
|
|
|
|
#[inline]
|
|
pub fn emit_string<S: Into<String>>(b: &mut MirBuilder, s: S) -> ValueId {
|
|
let dst = b.next_value_id();
|
|
let _ = b.emit_instruction(MirInstruction::Const {
|
|
dst,
|
|
value: ConstValue::String(s.into()),
|
|
});
|
|
// 🎯 Phase 3-A: String constant type annotation
|
|
// Ensures string constants have proper Box type for method resolution
|
|
b.type_ctx
|
|
.value_types
|
|
.insert(dst, crate::mir::MirType::Box("StringBox".to_string()));
|
|
b.type_ctx
|
|
.value_origin_newbox
|
|
.insert(dst, "StringBox".to_string());
|
|
dst
|
|
}
|
|
|
|
#[inline]
|
|
pub fn emit_null(b: &mut MirBuilder) -> ValueId {
|
|
let dst = b.next_value_id();
|
|
let _ = b.emit_instruction(MirInstruction::Const {
|
|
dst,
|
|
value: ConstValue::Null,
|
|
});
|
|
// Phase 84-1: Null constant type annotation
|
|
// Note: MirType has no Null variant, using Unknown as fallback
|
|
b.type_ctx
|
|
.value_types
|
|
.insert(dst, crate::mir::MirType::Unknown);
|
|
dst
|
|
}
|
|
|
|
#[inline]
|
|
pub fn emit_void(b: &mut MirBuilder) -> ValueId {
|
|
let dst = b.next_value_id();
|
|
let _ = b.emit_instruction(MirInstruction::Const {
|
|
dst,
|
|
value: ConstValue::Void,
|
|
});
|
|
// Phase 84-1: Void constant type annotation
|
|
b.type_ctx
|
|
.value_types
|
|
.insert(dst, crate::mir::MirType::Void);
|
|
dst
|
|
}
|