- tpc_build/tpc_run_test/tpv_build/tpv_compile_project 的 asan 默认 true - tpv_build 新增 asan 参数(编译器自身 ASan 插桩,崩溃时可输出报告定位) - tpv_bootstrap Phase A 对齐 tpv_build 加 --asan - includes/coro.vp: 裸 null 改 t.CPtr(0)(TPV 兼容,M1 遗留未提交)
52 lines
1.6 KiB
Plaintext
52 lines
1.6 KiB
Plaintext
import t, c
|
||
from stdint import *
|
||
import stdlib
|
||
|
||
|
||
@t.CVTable
|
||
class Coroutine:
|
||
"""协程帧句柄(M1:__ptr__ 持有 create_<name>() 返回的帧指针)"""
|
||
__ptr__: t.CPtr
|
||
|
||
|
||
def coro_resume(c: Coroutine) -> t.CInt:
|
||
# M1 占位:实际由编译器将 coro.coro_run 内联翻译为 resume_<name> 循环,
|
||
# 本函数不会被真正调用(仅保证模块可编译)。
|
||
return 0
|
||
|
||
|
||
def coro_result(c: Coroutine) -> t.CInt:
|
||
# M1 占位:coro_run 内联翻译直接从帧 ret 槽取结果。
|
||
return 0
|
||
|
||
|
||
def coro_run(c: Coroutine) -> t.CInt:
|
||
# M1 占位实现:编译器在调用点对 coro.coro_run 做内联翻译(resume 循环)。
|
||
s: t.CInt = 0
|
||
while s == 0:
|
||
s = coro_resume(c)
|
||
return coro_result(c)
|
||
|
||
def coro_sleep(ms: t.CInt) -> t.CInt:
|
||
# M3 占位:编译器将 await coro_sleep(ms) 内联翻译为帧 wake 槽挂起,
|
||
# 本函数不会被真正调用(仅保证模块可编译)。
|
||
return 0
|
||
|
||
|
||
def coro_destroy(c: Coroutine) -> t.CVoid:
|
||
# M3 占位:编译器将 coro.coro_destroy(帧) 内联翻译为 free。
|
||
return
|
||
|
||
def coro_exception(c: Coroutine) -> t.CInt:
|
||
# M4 占位:编译器将 coro.coro_exception(帧) 内联翻译为帧 exc 槽读取。
|
||
return 0
|
||
|
||
def coro_gather(a: Coroutine) -> t.CInt:
|
||
# M4 占位:编译器将 coro.coro_gather(帧...) 内联翻译为并发推进循环。
|
||
return 0
|
||
|
||
def coro_exception_msg(c: Coroutine) -> t.CPtr:
|
||
# M7 占位:编译器将 coro.coro_exception_msg(帧) 内联翻译为帧 msg 槽读取。
|
||
# 注意:TPV(Viper)不支持裸 null,用 t.CPtr(0) 构造空指针(两编译器兼容)。
|
||
return t.CPtr(0)
|