feat: async functions with return values
- runtime: bux_async_return(value, size) copies result to task->result - runtime: bux_async_await returns void* result pointer - runtime: bux_async_result(handle) to retrieve result - sema: ekAwait returns *void - HIR: await lowered to bux_async_await returning *void - Example: async Compute() -> int with interleaved execution and result await
This commit is contained in:
+1
-1
@@ -770,7 +770,7 @@ proc lowerExpr(ctx: var LowerCtx, expr: Expr): HirNode =
|
||||
|
||||
of ekAwait:
|
||||
let lowered = ctx.lowerExpr(expr.exprAwaitOperand)
|
||||
return hirCall("bux_async_await", @[lowered], makeVoid(), loc)
|
||||
return hirCall("bux_async_await", @[lowered], makePointer(makeVoid()), loc)
|
||||
|
||||
else:
|
||||
return HirNode(kind: hLit, litToken: Token(kind: tkIntLiteral, text: "0", loc: loc),
|
||||
|
||||
+2
-2
@@ -1010,8 +1010,8 @@ proc checkExpr(sema: var Sema, expr: Expr, scope: Scope): Type =
|
||||
return makePointer(makeVoid())
|
||||
of ekAwait:
|
||||
let operand = sema.checkExpr(expr.exprAwaitOperand, scope)
|
||||
# await on a task handle returns void for now
|
||||
return makeVoid()
|
||||
# await on a task handle returns *void (result pointer)
|
||||
return makePointer(makeVoid())
|
||||
of ekSpread:
|
||||
return sema.checkExpr(expr.exprSpreadOperand, scope)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user