Phase 11-12: LLVM backend initial, semantics layer, plugin unification

Major changes:
- LLVM backend initial implementation (compiler.rs, llvm mode)
- Semantics layer integration in interpreter (operators.rs)
- Phase 12 plugin architecture revision (3-layer system)
- Builtin box removal preparation
- MIR instruction set documentation (26→Core-15 migration)
- Cross-backend testing infrastructure
- Await/nowait syntax support

New features:
- LLVM AOT compilation support (--backend llvm)
- Semantics layer for interpreter→VM flow
- Tri-backend smoke tests
- Plugin-only registry mode

Bug fixes:
- Interpreter plugin box arithmetic operations
- Branch test returns incorrect values

Documentation:
- Phase 12 README.md updated with new plugin architecture
- Removed obsolete NYIR proposals
- Added LLVM test programs documentation

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-09-01 23:44:34 +09:00
parent fff9749f47
commit 11506cee3b
196 changed files with 10955 additions and 380 deletions

View File

@ -0,0 +1,18 @@
// Chained await example
static box Main {
main() {
local f1, f2, r1, r2
// Create two futures
f1 = new FutureBox(10)
f2 = new FutureBox(20)
// Await both
r1 = await f1
r2 = await f2
// Return sum
return r1 + r2
}
}

17
examples/await_demo.nyash Normal file
View File

@ -0,0 +1,17 @@
// Await demo - demonstrates async/await functionality
static box Main {
main() {
local future, result
// Create a future with initial value
future = new FutureBox(42)
// Wait for the future to complete and get value
result = await future
print("Awaited result: " + result.toString())
return result
}
}

View File

@ -0,0 +1,14 @@
// Simple await example for testing MIR Await instruction
static box Main {
main() {
local f
f = me.createFuture()
return await f
}
createFuture() {
// Simple future that resolves to 100
return new FutureBox(100)
}
}

View File

@ -0,0 +1,12 @@
// Test await without FutureBox (using integer for now)
static box Main {
main() {
local value
value = 42
// Note: await expects a future, but we'll test with integer
// This should fail, but will show if await instruction is recognized
return await value
}
}

View File

@ -0,0 +1,16 @@
// Semantics test - Array operations
static box Main {
main() {
local arr, value
arr = new ArrayBox()
// ArrayGet/ArraySet test
arr.push(10)
arr.push(20)
arr.push(30)
value = arr.get(1) // Should be 20
return value
}
}

View File

@ -0,0 +1,17 @@
// Semantics test - Branch/Phi example
static box Main {
main() {
local x, y, result
x = 10
y = 20
if x < y {
result = 100
} else {
result = 200
}
return result // Should be 100
}
}

View File

@ -0,0 +1,8 @@
// Semantics test - ExternCall (console.log)
static box Main {
main() {
print("Hello from semantics test!")
return 42
}
}

View File

@ -0,0 +1,12 @@
// Simple test without await
static box Main {
main() {
local x, y, result
x = 10
y = 20
result = x + y
print("Result: " + result.toString())
return result
}
}