feat(llvm): Phase 97 - Call/PHI/Plugin強化 + リファクタリング準備
## 概要 LLVM backend のCall処理、PHI wiring、Plugin loader を強化。 次のリファクタリング(箱化モジュール化)のための準備も含む。 ## 変更内容 ### LLVM Call処理強化 - `mir_call/__init__.py`: Call ルーティングロジック改善 - `mir_call/global_call.py`: print処理の marshal強化 - `mir_call/method_call.py`: メソッド呼び出し処理改善 - `boxcall.py`: BoxCall処理改善 ### PHI処理強化 - `phi_manager.py`: PHI管理改善 - `phi_wiring/wiring.py`: PHI配線ロジック強化(+17行) - `phi_wiring/tagging.py`: Type tagging改善 - `resolver.py`: Value解決ロジック強化(+34行) ### Copy伝播 - `copy.py`: Copy命令のType tag伝播追加(+10行) ### Plugin loader強化 - `library.rs`: エラー出力改善、[plugin/missing]ログ追加(+34行) - fail-fast強化 ### テスト - `phase97_json_loader_escape_llvm_exe.sh`: Phase 97 E2Eテスト追加 - `phase97_next_non_ws_llvm_exe.sh`: Phase 97 E2Eテスト追加 ### その他 - `nyash_kernel/lib.rs`: Kernel側の改善(+23行) ## 統計 - 14ファイル変更 - +256行 / -53行 = +203 net ## 次のリファクタリング準備 以下の箇所がリファクタリング対象として識別済み: 1. Call ルーティング箱の明文化 2. print の marshal 箱 3. TypeFacts/Tagging 箱の一本化 4. PHI Snapshot 契約のSSOT 5. Plugin loader のエラー出力統合 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -97,7 +97,24 @@ class Resolver:
|
||||
|
||||
def mark_string(self, value_id: int) -> None:
|
||||
try:
|
||||
self.string_ids.add(int(value_id))
|
||||
vid = int(value_id)
|
||||
self.string_ids.add(vid)
|
||||
# TypeFacts SSOT: keep value_types in sync so downstream decisions
|
||||
# (e.g., '+' concat tag checks) can treat this as a StringBox handle.
|
||||
try:
|
||||
if not hasattr(self, 'value_types') or self.value_types is None:
|
||||
self.value_types = {}
|
||||
cur = self.value_types.get(vid) if isinstance(self.value_types, dict) else None
|
||||
is_already_string = False
|
||||
if isinstance(cur, dict):
|
||||
if cur.get('kind') == 'string':
|
||||
is_already_string = True
|
||||
if cur.get('kind') == 'handle' and cur.get('box_type') == 'StringBox':
|
||||
is_already_string = True
|
||||
if not is_already_string and isinstance(self.value_types, dict):
|
||||
self.value_types[vid] = {'kind': 'handle', 'box_type': 'StringBox'}
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@ -478,16 +495,11 @@ class Resolver:
|
||||
except Exception:
|
||||
pass
|
||||
if is_phi_val:
|
||||
# Accept PHI only when it belongs to the same block (dominates end-of-block).
|
||||
try:
|
||||
belongs_here = (getattr(getattr(val, 'basic_block', None), 'name', b'').decode() if hasattr(getattr(val, 'basic_block', None), 'name') else str(getattr(getattr(val, 'basic_block', None), 'name', ''))) == f"bb{block_id}"
|
||||
except Exception:
|
||||
belongs_here = False
|
||||
if belongs_here:
|
||||
coerced = self._coerce_in_block_to_i64(val, block_id, bb_map)
|
||||
self._end_i64_cache[key] = coerced
|
||||
return coerced
|
||||
# Otherwise, PHI from wrong block -> treat as miss
|
||||
# PHIs are valid SSA values to carry through snapshots: a PHI defined at a
|
||||
# dominating block head can be used at the end of successor blocks.
|
||||
coerced = self._coerce_in_block_to_i64(val, block_id, bb_map)
|
||||
self._end_i64_cache[key] = coerced
|
||||
return coerced
|
||||
else:
|
||||
coerced = self._coerce_in_block_to_i64(val, block_id, bb_map)
|
||||
self._end_i64_cache[key] = coerced
|
||||
|
||||
Reference in New Issue
Block a user