feat(phase33): mir_call.hako Stages 2-4 complete - 全段階実装完了 🎉
Stage 2: CallEmitBox拡張 (+12 lines) - make_mir_call_closure(params, captures, me_capture, dst) - make_mir_call_value(func_vid, arg_ids, dst) Stage 3: mir_call.hako簡略化 (208→164 lines, -21.2%) - CallEmitBox完全活用により手動JSON生成を削除 - 74.4%削減達成 (Python 641→Hakorune 164 lines) Stage 4: Smoke Tests追加 (+102 lines) - closure_simple.hako: Closure callee typeテスト - value_simple.hako: Value callee typeテスト Phase 33 Final Achievement: ✅ 10/10 instructions 完全実装 (100%) - Phase v0: const, binop, compare, ret (4/4) - Phase v1: branch, jump, copy (3/3) - Phase v2-A: phi (1/1) - Phase v2-B: loopform (1/1) - Phase v2-C: mir_call (1/1) ← NEW! Test Coverage: - Unit tests: 288 lines (6 tests, all callee types) - Smoke tests: 147 lines (3 tests) - Total: 435 lines test coverage 🚀 Python → Hakorune Script 移行 100% 完了!
This commit is contained in:
58
tests/phase33/smoke/mir_call/closure_simple.hako
Normal file
58
tests/phase33/smoke/mir_call/closure_simple.hako
Normal file
@ -0,0 +1,58 @@
|
||||
// MIR Call Smoke Test 2: Closure creation
|
||||
// Tests Closure callee type
|
||||
|
||||
using "lang/src/llvm_ir/instructions/mir_call.hako" as MirCallInst
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
print("=== MIR Call Smoke Test 2: closure_simple ===")
|
||||
|
||||
// Simulate: |x, y| { x + y }
|
||||
local callee = new MapBox()
|
||||
callee.set("type", "Closure")
|
||||
|
||||
local params = new ArrayBox()
|
||||
params.push(1) // param x
|
||||
params.push(2) // param y
|
||||
callee.set("params", params)
|
||||
|
||||
local captures = new ArrayBox()
|
||||
captures.push(3) // captured variable
|
||||
callee.set("captures", captures)
|
||||
|
||||
local args = new ArrayBox()
|
||||
|
||||
// Generate mir_call JSON
|
||||
local json = MirCallInst.lower_mir_call(null, callee, args, 4, null)
|
||||
|
||||
// Verify JSON structure
|
||||
local has_mir_call = json.indexOf("\"op\":\"mir_call\"")
|
||||
if has_mir_call < 0 {
|
||||
print("ERROR: op not found")
|
||||
return 1
|
||||
}
|
||||
|
||||
local has_closure = json.indexOf("\"type\":\"Closure\"")
|
||||
if has_closure < 0 {
|
||||
print("ERROR: Closure type not found")
|
||||
return 1
|
||||
}
|
||||
|
||||
local has_params = json.indexOf("\"params\"")
|
||||
if has_params < 0 {
|
||||
print("ERROR: params not found")
|
||||
return 1
|
||||
}
|
||||
|
||||
local has_captures = json.indexOf("\"captures\"")
|
||||
if has_captures < 0 {
|
||||
print("ERROR: captures not found")
|
||||
return 1
|
||||
}
|
||||
|
||||
print("✓ PASS: closure_simple mir_call generated")
|
||||
print("Note: Actual execution requires C++ backend implementation")
|
||||
|
||||
return 0
|
||||
}
|
||||
}
|
||||
46
tests/phase33/smoke/mir_call/value_simple.hako
Normal file
46
tests/phase33/smoke/mir_call/value_simple.hako
Normal file
@ -0,0 +1,46 @@
|
||||
// MIR Call Smoke Test 3: Value call (dynamic function)
|
||||
// Tests Value callee type
|
||||
|
||||
using "lang/src/llvm_ir/instructions/mir_call.hako" as MirCallInst
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
print("=== MIR Call Smoke Test 3: value_simple ===")
|
||||
|
||||
// Simulate: func_value(arg1, arg2)
|
||||
local callee = new MapBox()
|
||||
callee.set("type", "Value")
|
||||
callee.set("value", 5) // register holding function value
|
||||
|
||||
local args = new ArrayBox()
|
||||
args.push(6) // arg1
|
||||
args.push(7) // arg2
|
||||
|
||||
// Generate mir_call JSON
|
||||
local json = MirCallInst.lower_mir_call(null, callee, args, 8, null)
|
||||
|
||||
// Verify JSON structure
|
||||
local has_mir_call = json.indexOf("\"op\":\"mir_call\"")
|
||||
if has_mir_call < 0 {
|
||||
print("ERROR: op not found")
|
||||
return 1
|
||||
}
|
||||
|
||||
local has_value = json.indexOf("\"type\":\"Value\"")
|
||||
if has_value < 0 {
|
||||
print("ERROR: Value type not found")
|
||||
return 1
|
||||
}
|
||||
|
||||
local has_value_id = json.indexOf("\"value\":5")
|
||||
if has_value_id < 0 {
|
||||
print("ERROR: value ID not found")
|
||||
return 1
|
||||
}
|
||||
|
||||
print("✓ PASS: value_simple mir_call generated")
|
||||
print("Note: Actual execution requires C++ backend implementation")
|
||||
|
||||
return 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user