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:
18
examples/await_chain.nyash
Normal file
18
examples/await_chain.nyash
Normal 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
17
examples/await_demo.nyash
Normal 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
|
||||
}
|
||||
}
|
||||
14
examples/await_simple.nyash
Normal file
14
examples/await_simple.nyash
Normal 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)
|
||||
}
|
||||
}
|
||||
12
examples/await_test_vm.nyash
Normal file
12
examples/await_test_vm.nyash
Normal 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
|
||||
}
|
||||
}
|
||||
16
examples/semantics_test_array.nyash
Normal file
16
examples/semantics_test_array.nyash
Normal 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
|
||||
}
|
||||
}
|
||||
17
examples/semantics_test_branch.nyash
Normal file
17
examples/semantics_test_branch.nyash
Normal 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
|
||||
}
|
||||
}
|
||||
8
examples/semantics_test_extern.nyash
Normal file
8
examples/semantics_test_extern.nyash
Normal file
@ -0,0 +1,8 @@
|
||||
// Semantics test - ExternCall (console.log)
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
print("Hello from semantics test!")
|
||||
return 42
|
||||
}
|
||||
}
|
||||
12
examples/simple_test.nyash
Normal file
12
examples/simple_test.nyash
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user