feat: Phase 8.3 Concurrency — tasks, channels, spawn
- Add async/await/spawn keywords to lexer - C runtime: pthread wrappers (bux_task_spawn, bux_task_join, bux_task_sleep) - C runtime: mutex/condvar channel implementation (bux_channel_new/send/recv/close/free) - Build command adds -pthread flag for C compilation - Std::Task module: TaskHandle, Task_Spawn, Task_Join, Task_Sleep - Std::Channel module: generic Channel<T> with Send, Recv, Close, Free - Parser: spawn Expr() expression - Sema: ekSpawn returns *void - HIR: hSpawn node lowered from ekSpawn - C backend: emit bux_task_spawn(FuncName, arg) for spawn expressions - Example: examples/concurrency.bux (thread + channel demo) - Example: examples_pkg/concurrency working project
This commit is contained in:
@@ -252,6 +252,16 @@ proc emitExpr(be: var CBackend, node: HirNode): string =
|
||||
let typ = typeToC(node.sizeOfType)
|
||||
return &"sizeof({typ})"
|
||||
|
||||
of hSpawn:
|
||||
var argsStr = ""
|
||||
if node.spawnArgs.len > 0:
|
||||
# Package arguments into a heap-allocated struct (simplified: single arg)
|
||||
let arg = be.emitExpr(node.spawnArgs[0])
|
||||
argsStr = &"(void*){arg}"
|
||||
else:
|
||||
argsStr = "NULL"
|
||||
return &"bux_task_spawn({node.spawnCallee}, {argsStr})"
|
||||
|
||||
of hIf:
|
||||
# Ternary expression
|
||||
let cond = be.emitExpr(node.ifCond)
|
||||
|
||||
Reference in New Issue
Block a user