✨ Implement JSON v0 Bridge with full PHI support for If/Loop statements
Major implementation by ChatGPT: - Complete JSON v0 Bridge layer with PHI generation for control flow - If statement: Merge PHI nodes for variables updated in then/else branches - Loop statement: Header PHI nodes for loop-carried dependencies - Python MVP Parser Stage-2: Added local/if/loop/call/method/new support - Full CFG guarantee: All blocks have proper terminators (branch/jump/return) - Type metadata for string operations (+, ==, !=) - Comprehensive PHI smoke tests for nested and edge cases This allows MIR generation without Rust MIR builder - massive step towards eliminating Rust build dependency! 🎉 ChatGPTが30分以上かけて実装してくれたにゃ! Co-Authored-By: ChatGPT <noreply@openai.com>
This commit is contained in:
14
apps/tests/loop_if_phi.nyash
Normal file
14
apps/tests/loop_if_phi.nyash
Normal file
@ -0,0 +1,14 @@
|
||||
static box Main {
|
||||
main(args) {
|
||||
local console = new ConsoleBox()
|
||||
local i = 1
|
||||
local sum = 0
|
||||
loop(i <= 5) {
|
||||
if (i % 2 == 1) { sum = sum + i } else { sum = sum + 0 }
|
||||
i = i + 1
|
||||
}
|
||||
console.println("sum=" + sum)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
12
apps/tests/me_method_call.nyash
Normal file
12
apps/tests/me_method_call.nyash
Normal file
@ -0,0 +1,12 @@
|
||||
static box Main {
|
||||
helper(s) {
|
||||
return s.length()
|
||||
}
|
||||
main(args) {
|
||||
local console = new ConsoleBox()
|
||||
local n = me.helper("abc")
|
||||
console.println("n=" + n)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
15
apps/tests/string_ops_basic.nyash
Normal file
15
apps/tests/string_ops_basic.nyash
Normal file
@ -0,0 +1,15 @@
|
||||
static box Main {
|
||||
main(args) {
|
||||
local console = new ConsoleBox()
|
||||
local s = "abcde"
|
||||
// length
|
||||
console.println("len=" + s.length())
|
||||
// substring [1,4) -> bcd
|
||||
local t = s.substring(1, 4)
|
||||
console.println("sub=" + t)
|
||||
// lastIndexOf("b") -> 1
|
||||
console.println("idx=" + s.lastIndexOf("b"))
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user