Files

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: VPC (Viper) does not support bare null; use t.CPtr(0) to build a null pointer (compatible with both compilers).
return None