refactor(mir): Phase 139-P3-B - RoutingDecision を enum 対応 + レガシー削除

- RoutingDecision の missing_caps を Vec<CapabilityTag> に変更(型安全化)
- error_tags は to_tag() メソッドで自動生成
- 全 callsite を enum variant に修正
- capability_tags モジュール(文字列定数群)を完全削除
- 全テスト PASS(型安全性向上を確認)
- フォーマット適用
This commit is contained in:
nyash-codex
2025-12-16 07:02:14 +09:00
parent 146f14a019
commit e404746612
106 changed files with 1475 additions and 1017 deletions

View File

@ -16,7 +16,12 @@ impl super::MirBuilder {
// Unified members: if object class is known and has a synthetic getter for `field`,
// rewrite to method call `__get_<field>()`.
if let Some(class_name) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
if let Some(class_name) = self
.type_ctx
.value_origin_newbox
.get(&object_value)
.cloned()
{
if let Some(map) = self.comp_ctx.property_getters_by_box.get(&class_name) {
if let Some(kind) = map.get(&field) {
let mname = match kind {
@ -53,15 +58,24 @@ impl super::MirBuilder {
// Propagate recorded origin class for this field if any (ValueId-scoped)
if let Some(class_name) = self
.comp_ctx.field_origin_class
.comp_ctx
.field_origin_class
.get(&(object_value, field.clone()))
.cloned()
{
self.type_ctx.value_origin_newbox.insert(field_val, class_name);
} else if let Some(base_cls) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
self.type_ctx
.value_origin_newbox
.insert(field_val, class_name);
} else if let Some(base_cls) = self
.type_ctx
.value_origin_newbox
.get(&object_value)
.cloned()
{
// Cross-function heuristic: use class-level field origin mapping
if let Some(fcls) = self
.comp_ctx.field_origin_by_box
.comp_ctx
.field_origin_by_box
.get(&(base_cls.clone(), field.clone()))
.cloned()
{
@ -78,8 +92,11 @@ impl super::MirBuilder {
}
// If base is a known newbox and field is weak, emit WeakLoad (+ optional barrier)
let mut inferred_class: Option<String> =
self.type_ctx.value_origin_newbox.get(&object_value).cloned();
let mut inferred_class: Option<String> = self
.type_ctx
.value_origin_newbox
.get(&object_value)
.cloned();
if inferred_class.is_none() {
if let ASTNode::FieldAccess {
object: inner_obj,
@ -89,7 +106,8 @@ impl super::MirBuilder {
{
if let Ok(base_id) = self.build_expression(*inner_obj.clone()) {
if let Some(cls) = self
.comp_ctx.field_origin_class
.comp_ctx
.field_origin_class
.get(&(base_id, inner_field))
.cloned()
{
@ -128,7 +146,12 @@ impl super::MirBuilder {
value_result = self.local_arg(value_result);
// If base is known and field is weak, create WeakRef before store
if let Some(class_name) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
if let Some(class_name) = self
.type_ctx
.value_origin_newbox
.get(&object_value)
.cloned()
{
if let Some(weak_set) = self.comp_ctx.weak_fields_by_box.get(&class_name) {
if weak_set.contains(&field) {
value_result = self.emit_weak_new(value_result)?;
@ -158,7 +181,12 @@ impl super::MirBuilder {
})?;
// Write barrier if weak field
if let Some(class_name) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
if let Some(class_name) = self
.type_ctx
.value_origin_newbox
.get(&object_value)
.cloned()
{
if let Some(weak_set) = self.comp_ctx.weak_fields_by_box.get(&class_name) {
if weak_set.contains(&field) {
let _ = self.emit_barrier_write(value_result);
@ -167,12 +195,24 @@ impl super::MirBuilder {
}
// Record origin class for this field value if known
if let Some(val_cls) = self.type_ctx.value_origin_newbox.get(&value_result).cloned() {
self.comp_ctx.field_origin_class
if let Some(val_cls) = self
.type_ctx
.value_origin_newbox
.get(&value_result)
.cloned()
{
self.comp_ctx
.field_origin_class
.insert((object_value, field.clone()), val_cls.clone());
// Also record class-level mapping if base object class is known
if let Some(base_cls) = self.type_ctx.value_origin_newbox.get(&object_value).cloned() {
self.comp_ctx.field_origin_by_box
if let Some(base_cls) = self
.type_ctx
.value_origin_newbox
.get(&object_value)
.cloned()
{
self.comp_ctx
.field_origin_by_box
.insert((base_cls, field.clone()), val_cls);
}
}