fix(phase161): Use ArrayBox.get() instead of at() for VM compatibility

- 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 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-04 20:13:21 +09:00
parent 9f2c791f2a
commit 694a5ebadd
3 changed files with 14 additions and 15 deletions

View File

@ -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
}

View File

@ -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")

View File

@ -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" {