From 694a5ebaddcb8c13a0ae6160f4322c5248c1ed66 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Thu, 4 Dec 2025 20:13:21 +0900 Subject: [PATCH] fix(phase161): Use ArrayBox.get() instead of at() for VM compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace .at() with .get() in mir_analyzer.hako (10 occurrences) - Fix test_rep1_inline.hako and test_mir_analyzer.hako - Builtin ArrayBox only supports .get(), not .at() Phase 161-2 MIR JSON parsing tests now pass: - JSON object parsing: PASS - functions array extraction: PASS - Function name extraction: PASS - blocks extraction: PASS - PHI instruction detection: PASS (found PHI at block=10 dst=r30) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- local_tests/phase161/test_mir_analyzer.hako | 7 +++---- local_tests/phase161/test_rep1_inline.hako | 2 +- tools/hako_shared/mir_analyzer.hako | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/local_tests/phase161/test_mir_analyzer.hako b/local_tests/phase161/test_mir_analyzer.hako index 1ad5e64e..5d3e87e1 100644 --- a/local_tests/phase161/test_mir_analyzer.hako +++ b/local_tests/phase161/test_mir_analyzer.hako @@ -12,11 +12,10 @@ box TestRunner { print("Test: " + name) print("==================================================") - // Parse MIR JSON - me.analyzer = new MirAnalyzerBox() - local result = me.analyzer.birth(mir_json_text) + // Parse MIR JSON - use constructor directly + me.analyzer = new MirAnalyzerBox(mir_json_text) - if result == null { + if me.analyzer == null { print("FAIL: Failed to parse MIR JSON") return null } diff --git a/local_tests/phase161/test_rep1_inline.hako b/local_tests/phase161/test_rep1_inline.hako index aec9eadc..77826926 100644 --- a/local_tests/phase161/test_rep1_inline.hako +++ b/local_tests/phase161/test_rep1_inline.hako @@ -113,7 +113,7 @@ static box Main { print(" [OK] Correct PHI count (1)") pass_count = pass_count + 1 - local phi = phi_list.at(0) + local phi = phi_list.get(0) local block_id = phi.get("block_id") local dest = phi.get("dest") local incoming_count = phi.get("incoming_count") diff --git a/tools/hako_shared/mir_analyzer.hako b/tools/hako_shared/mir_analyzer.hako index 19b11f04..19d2278e 100644 --- a/tools/hako_shared/mir_analyzer.hako +++ b/tools/hako_shared/mir_analyzer.hako @@ -106,7 +106,7 @@ box MirAnalyzerBox { local i = 0 loop(i < blocks.size()) { - local block = blocks.at(i) + local block = blocks.get(i) local instructions = block.get("instructions") if instructions != null { @@ -115,7 +115,7 @@ box MirAnalyzerBox { // Check for PHI and Branch instructions local j = 0 loop(j < instructions.size()) { - local inst = instructions.at(j) + local inst = instructions.get(j) local op = inst.get("op") if op == "phi" { @@ -171,14 +171,14 @@ box MirAnalyzerBox { local i = 0 loop(i < blocks.size()) { - local block = blocks.at(i) + local block = blocks.get(i) local block_id = block.get("id") local instructions = block.get("instructions") if instructions != null { local j = 0 loop(j < instructions.size()) { - local inst = instructions.at(j) + local inst = instructions.get(j) local op = inst.get("op") if op == "phi" { @@ -230,7 +230,7 @@ box MirAnalyzerBox { local block_map = new MapBox() local i = 0 loop(i < blocks.size()) { - local block = blocks.at(i) + local block = blocks.get(i) local block_id = block.get("id") block_map.set("" + block_id, i) i = i + 1 @@ -241,7 +241,7 @@ box MirAnalyzerBox { i = 0 loop(i < blocks.size()) { - local block = blocks.at(i) + local block = blocks.get(i) local block_id = block.get("id") local instructions = block.get("instructions") @@ -249,7 +249,7 @@ box MirAnalyzerBox { // Check last instruction for control flow local last_idx = instructions.size() - 1 if last_idx >= 0 { - local last_inst = instructions.at(last_idx) + local last_inst = instructions.get(last_idx) local op = last_inst.get("op") // Check jump instruction @@ -316,7 +316,7 @@ box MirAnalyzerBox { if funcIndex < 0 { return null } if funcIndex >= me._functions.size() { return null } - return me._functions.at(funcIndex) + return me._functions.get(funcIndex) } // Internal: Check if function has backward edges (loop indicator) @@ -325,14 +325,14 @@ box MirAnalyzerBox { local i = 0 loop(i < blocks.size()) { - local block = blocks.at(i) + local block = blocks.get(i) local block_id = block.get("id") local instructions = block.get("instructions") if instructions != null { local last_idx = instructions.size() - 1 if last_idx >= 0 { - local last_inst = instructions.at(last_idx) + local last_inst = instructions.get(last_idx) local op = last_inst.get("op") if op == "jump" {