feat(joinir): Phase 224-B - MethodCallLowerer + CoreMethodId extension
- Extend CoreMethodId with is_pure(), allowed_in_condition(), allowed_in_init() - New MethodCallLowerer box for metadata-driven MethodCall lowering - Integrate MethodCall handling in condition_lowerer - P0: Zero-argument methods (length) supported - Design principle: NO method name hardcoding, CoreMethodId metadata only 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
25
apps/tests/phase224b_method_call_captured.hako
Normal file
25
apps/tests/phase224b_method_call_captured.hako
Normal file
@ -0,0 +1,25 @@
|
||||
// Phase 224-B: MethodCall lowering test - s.length() with captured variable
|
||||
//
|
||||
// Test case: Loop using s.length() where s is passed as parameter (captured)
|
||||
// This prevents constant folding and forces MethodCall lowering
|
||||
//
|
||||
// Pattern 2: Loop with captured variable
|
||||
|
||||
static box Main {
|
||||
helper(text) {
|
||||
local i = 0
|
||||
|
||||
// Pattern 1 loop with MethodCall in condition (text is captured)
|
||||
loop(i < text.length()) {
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
main() {
|
||||
local result = me.helper("Hello")
|
||||
print("result = " + result)
|
||||
return result
|
||||
}
|
||||
}
|
||||
22
apps/tests/phase224b_method_call_min.hako
Normal file
22
apps/tests/phase224b_method_call_min.hako
Normal file
@ -0,0 +1,22 @@
|
||||
// Phase 224-B: MethodCall lowering test - s.length() in loop condition
|
||||
//
|
||||
// Test case: Simple loop using s.length() in condition
|
||||
// Expected: MethodCall should be lowered to BoxCall instruction
|
||||
//
|
||||
// Pattern 1: Simple while loop (no break, no continue)
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local s = "Hello"
|
||||
local i = 0
|
||||
|
||||
// Pattern 1 loop with MethodCall in condition
|
||||
loop(i < s.length()) {
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
// Output result
|
||||
print("i = " + i)
|
||||
return i
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user