diff --git a/lang/src/llvm_ir/instructions/phi.hako b/lang/src/llvm_ir/instructions/phi.hako index d809b0f7..54d8c51b 100644 --- a/lang/src/llvm_ir/instructions/phi.hako +++ b/lang/src/llvm_ir/instructions/phi.hako @@ -19,7 +19,7 @@ static box LLVMPhiInstructionBox { // Returns: // JSON文字列: {"op":"phi","dst":5,"incoming":[...]} // - lower_phi(dst, incoming_list) { + lower_phi(self, dst, incoming_list) { // 空チェック: incoming が空の場合は 0 定数を返す // Python: phi.py 34-37行の動作と同じ if incoming_list == null { @@ -41,7 +41,7 @@ static box LLVMPhiInstructionBox { // 空のPHI: 0定数にフォールバック // Python: phi.py 34-37行 - _phi_empty_fallback(dst) { + _phi_empty_fallback(self, dst) { // No incoming edges - use zero constant return "{\"op\":\"const\",\"dst\":" + dst + ",\"value\":{\"type\":\"i64\",\"value\":0}}" } @@ -54,7 +54,7 @@ static box LLVMPhiInstructionBox { // Returns: // JSON配列文字列: [{"value":1,"block":1},{"value":2,"block":2}] // - _build_incoming_array(incoming_list) { + _build_incoming_array(self, incoming_list) { local result = "[" local first = 1 @@ -86,8 +86,8 @@ static box LLVMPhiInstructionBox { } // デバッグ用 - 生成された命令の確認 - debug_phi(dst, incoming_list) { - local json = me.lower_phi(dst, incoming_list) + debug_phi(self, dst, incoming_list) { + local json = me.lower_phi(self, dst, incoming_list) print("Generated PHI instruction: " + json) return json } @@ -95,33 +95,33 @@ static box LLVMPhiInstructionBox { // Stage 2 プレースホルダー: Block End Values管理(将来実装) // Python: phi.py 69-79行の block_end_values スナップショット処理 // 注: Hakorune版では不要(C++バックエンドが処理) - lower_phi_with_snapshot(dst, incoming_list, block_end_values) { + lower_phi_with_snapshot(self, dst, incoming_list, block_end_values) { // 現時点では基本版と同じ動作 - return me.lower_phi(dst, incoming_list) + return me.lower_phi(self, incoming_list) } // Stage 3 プレースホルダー: 型変換処理(将来実装) // Python: phi.py 84-103行の型変換処理 // 注: Hakorune版では不要(C++バックエンドが処理) - lower_phi_with_type_info(dst, incoming_list, type_info) { + lower_phi_with_type_info(self, dst, incoming_list, type_info) { // 現時点では基本版と同じ動作 - return me.lower_phi(dst, incoming_list) + return me.lower_phi(self, incoming_list) } // Stage 4 プレースホルダー: Strict Mode(将来実装) // Python: phi.py 118-121行の NYASH_LLVM_PHI_STRICT チェック // 注: C++バックエンドで実装予定 - lower_phi_strict(dst, incoming_list, strict_mode) { + lower_phi_strict(self, dst, incoming_list, strict_mode) { // 現時点では基本版と同じ動作 - return me.lower_phi(dst, incoming_list) + return me.lower_phi(self, incoming_list) } // Stage 5 プレースホルダー: 文字列性伝播(将来実装) // Python: phi.py 131-142行の resolver.is_stringish() 処理 // 注: C++バックエンドで実装予定 - lower_phi_with_string_propagation(dst, incoming_list, resolver) { + lower_phi_with_string_propagation(self, dst, incoming_list, resolver) { // 現時点では基本版と同じ動作 - return me.lower_phi(dst, incoming_list) + return me.lower_phi(self, incoming_list) } // ヘルパー: incoming要素の検証(デバッグ用) diff --git a/tools/smokes/v2/profiles/quick/core/phi/self_param_phi_vm.sh b/tools/smokes/v2/profiles/quick/core/phi/self_param_phi_vm.sh new file mode 100644 index 00000000..2dcd8e53 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/phi/self_param_phi_vm.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Verify LLVMPhiInstructionBox.lower_phi requires self (implicit receiver) and returns JSON + +source "$(dirname "$0")/../../../lib/test_runner.sh" +source "$(dirname "$0")/../../../lib/result_checker.sh" + +require_env || exit 2 +preflight_plugins || exit 2 + +test_self_param_phi() { + local src=' +using "lang/src/llvm_ir/instructions/phi.hako" as PhiInst +box Main { + static method main() { + local incoming = new ArrayBox() + local item = new MapBox(); item.set("value", 1); item.set("block", 0); incoming.push(item) + local phi = new PhiInst.LLVMPhiInstructionBox().lower_phi(5, incoming) + # 判定: 生成文字列に op":"phi が含まれるか(最小) + if phi.contains("\"op\":\"phi\"") { print(1) } else { print(0) } + } +} +' + local out + out=$(run_nyash_vm -c "$src" 2>&1) + check_exact "1" "$out" "self_param_phi" +} + +run_test "self_param_phi" test_self_param_phi +