Files
Viper_VRTE/coro.vp
T
TermiNexus e25e8958f0 WIP 快照:includes 现有改动(含 M2.4 new 描述符的语法支持)
语法侧(M2.4):ast/base.vp 枚举尾部追加 ASTKind.New;ast/exprs.vp 新增 NEW_SRC_*/NEW_LIFE_* 与 class New;ast/parser.vp 新增 _is_new_expr/_parse_new_expr(new 为软关键字,不进 Keyword 表,new=1/new.x/new(1) 仍是标识符);ast/__init__.vp 再导出 New 与常量。

其余为既有 WIP 改动一并快照,保持基线一致(39 文件,+312/-237)。

未纳入:ctraits.vpi(已删除)、ctraits.vpnci、tomllib/(均未跟踪)。
2026-10-08 17:45:31 +08:00

45 lines
1.8 KiB
Plaintext

novirtual class Coroutine:
"""Coroutine frame handle (M1: __ptr__ holds the frame pointer returned by create_<name>()).
Pure handle semantics: never instantiated or polymorphically dispatched, the compiler intercepts all coro.* calls; user code uses t.CPtr as the handle."""
__ptr__: rawptr
def coro_resume(c: Coroutine) -> int:
# M1 placeholder: the compiler inlines coro.coro_run into a resume_<name> loop; this function is never actually called (it only keeps the module compilable).
return 0
def coro_result(c: Coroutine) -> int:
# M1 placeholder: coro_run's inline translation reads the result directly from the frame ret slot.
return 0
def coro_run(c: Coroutine) -> int:
# M1 placeholder: the compiler inlines coro.coro_run at the call site (resume loop).
s: int = 0
while s == 0:
s = coro_resume(c)
return coro_result(c)
def coro_sleep(ms: int) -> int:
# M3 placeholder: the compiler inlines await coro_sleep(ms) into a frame wake-slot suspend; this function is never actually called (it only keeps the module compilable).
return 0
def coro_destroy(c: Coroutine):
# M3 placeholder: the compiler inlines coro.coro_destroy(frame) into free.
return
def coro_exception(c: Coroutine) -> int:
# M4 placeholder: the compiler inlines coro.coro_exception(frame) into a frame exc-slot read.
return 0
def coro_gather(a: Coroutine) -> int:
# M4 placeholder: the compiler inlines coro.coro_gather(frames...) into a concurrent-advance loop.
return 0
def coro_exception_msg(c: Coroutine) -> rawptr:
# M7 placeholder: the compiler inlines coro.coro_exception_msg(frame) into a frame msg-slot read.
# Note: TPV (Viper) does not support bare null; use t.CPtr(0) to build a null pointer (compatible with both compilers).
return None