feat: Phase 8.3 async/await syntax + runtime

- AST: declFuncIsAsync flag, ekAwait expression kind
- Parser: async func declarations, expr.await postfix operator
- Sema: allow await anywhere (blocks current thread until task completes)
- HIR: ekAwait lowered to bux_task_join(handle) call
- C backend: async func emitted as regular function
- Example: examples/async.bux + examples_pkg/async project
- All 20 existing examples pass, selfhost build works
This commit is contained in:
2026-06-01 00:25:26 +03:00
parent 837fbb0487
commit d337ada4d6
5 changed files with 54 additions and 6 deletions
+4
View File
@@ -768,6 +768,10 @@ proc lowerExpr(ctx: var LowerCtx, expr: Expr): HirNode =
return HirNode(kind: hSpawn, spawnCallee: calleeName, spawnArgs: args,
typ: makePointer(makeVoid()), loc: loc)
of ekAwait:
let lowered = ctx.lowerExpr(expr.exprAwaitOperand)
return hirCall("bux_task_join", @[lowered], makeVoid(), loc)
else:
return HirNode(kind: hLit, litToken: Token(kind: tkIntLiteral, text: "0", loc: loc),
typ: makeVoid(), loc: loc)