feat(coro): M2——async 参数/嵌套 await 表达式/If-While 控制流

- 帧结构体增加参数槽与提升临时变量槽,create_<name> 带参数存入帧
- 嵌套 await(如 a = b + await f())提升为顶层临时赋值 __await_N,帧预留槽
- 协程版 If/While:条件求值 + 分支内 await 就地挂起/恢复(动态状态号恢复块)
- For 循环委托现有 handler(仅支持无 await/return,M3 扩展)
- CoroTest 用例覆盖参数/嵌套 await/while+await/if+await(期望 coro result = 30)
This commit is contained in:
TermiNexus committed 2026-08-21 13:31:37 +08:00
1 parent a775ec9932
commit ff7c0457ad
2 files changed
+423 -123

No files matched your search

+15 -8
View File
@@ -4,18 +4,25 @@ import stdio
import coro
async def leaf() -> int:
return 7
async def leaf(x: int) -> int:
return x + 1
async def task() -> int:
a: int = await leaf()
b: int = await leaf()
return a + b
async def task(base: int) -> int:
a: int = await leaf(base)
b: int = a * 2 + await leaf(a)
s: int = 0
i: int = 0
while i < 3:
s = s + await leaf(i)
i = i + 1
if s > 5:
s = s + await leaf(10)
return s + a + b
def main() -> t.CInt:
tt: coro.Coroutine = task()
tt: coro.Coroutine = task(2)
r: t.CInt = coro.coro_run(tt)
stdio.printf("coro result = %d\n", r)
return 0
return 0