feat: async/await/spawn + fix else-if lowering bug
Self-hosted compiler (buxc2):
- Add async/await/spawn tokens, parsing, HIR, lowering, C emission
- Fix pointer type emission (*T -> T*) in C backend
- Fix sizeof(Type) parsing with parentheses
- Fix import ::{...} infinite loop guard
- Fix int64 emission by avoiding else-if chain workaround
- Add debug-free cli and hir_lower
Bootstrap compiler (Nim):
- Fix critical else-if lowering bug in hir_lower.nim:
when both elseIfs and else block exist, elseIfs were dropped
causing all else-if chains to collapse to if+else only
Runtime:
- Fix bux_async_await memory corruption (don't free in run)
- Add bux_remove_from_ready for safe cleanup
- Fix forward declaration and deduplicate bux_now_ms
Docs & examples:
- Update async.bux example with proper int64 params
- Update README, LanguageRef, Stdlib, PLAN for async features
- Mark Phase 7.10 bootstrap loop as completed
All 27 examples pass. buxc2 check/build work on all examples.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Bux Programming Language
|
||||
|
||||
> **Status:** Bootstrap phase — compiler written in Nim, targeting self-hosting.
|
||||
> **Status:** Self-hosting phase — `buxc2` (Bux compiler written in Bux) compiles `.bux` files to C. Bootstrap compiler (`buxc`, Nim) maintains backward compatibility.
|
||||
|
||||
Bux is a fast, compiled, strongly-typed systems programming language inspired by [Rux](https://rux-lang.dev/). The long-term goal is a self-hosted compiler with a minimal runtime, native x86-64 backend, and modern tooling.
|
||||
|
||||
@@ -93,6 +93,25 @@ func Main() -> int {
|
||||
}
|
||||
```
|
||||
|
||||
### Async/Await
|
||||
```bux
|
||||
import Std::Io::{PrintLine, PrintInt};
|
||||
|
||||
async func Compute() -> int {
|
||||
PrintLine("Compute: step 1");
|
||||
bux_async_yield();
|
||||
PrintLine("Compute: step 2");
|
||||
return 42;
|
||||
}
|
||||
|
||||
func Main() -> int {
|
||||
let h1 = spawn Compute();
|
||||
let r1: int = h1.await as int;
|
||||
PrintInt(r1);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### Hash Map
|
||||
```bux
|
||||
import Std::Map::{Map, Map_New, Map_Set, Map_Get};
|
||||
@@ -119,8 +138,10 @@ func Main() -> int {
|
||||
| **Interfaces** | `interface` + `extend` for trait-like behavior |
|
||||
| **Error Handling** | `Result<T,E>`, `Option<T>`, and the `?` operator |
|
||||
| **Standard Library** | `Io`, `Array`, `String`, `Map` |
|
||||
| **Backend** | C transpiler (bootstrap) |
|
||||
| **Backend** | C transpiler (bootstrap) → self-hosting target |
|
||||
| **Gradual Ownership** | `@[Checked]` + `&T`/`&mut T` borrow checking |
|
||||
| **Async/Await** | `async func`, `spawn`, `.await` with stackful coroutines |
|
||||
| **Concurrency** | `Task`/`Channel` (pthread-based), `bux_async_yield`/`spawn` |
|
||||
| **CTFE** | `const func` — compile-time function execution |
|
||||
| **Trait Bounds** | `func Max<T: Comparable>(a: T, b: T) -> T` |
|
||||
| **Package Manager** | `bux add`, `bux install`, `bux.lock`, path + git deps |
|
||||
@@ -133,6 +154,8 @@ func Main() -> int {
|
||||
```
|
||||
bux/
|
||||
├── src/ # Bootstrap compiler (Nim)
|
||||
├── src_bux/ # Self-hosting compiler source (Bux)
|
||||
├── _selfhost/ # Self-hosting build artifacts
|
||||
├── stdlib/ # Standard library (.bux + .c runtime)
|
||||
├── examples/ # Example programs
|
||||
├── tests/ # Unit tests (Nim)
|
||||
@@ -147,9 +170,12 @@ bux/
|
||||
## Build & Test
|
||||
|
||||
```bash
|
||||
# Build compiler
|
||||
# Build bootstrap compiler (Nim)
|
||||
make build
|
||||
|
||||
# Build self-hosted compiler (Bux → C → binary)
|
||||
make selfhost
|
||||
|
||||
# Run all tests
|
||||
make test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user