MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lua_yieldk

Function lua_yieldk

freebsd/contrib/openzfs/module/lua/ldo.c:642–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

640
641
642LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) {
643 CallInfo *ci = L->ci;
644 luai_userstateyield(L, nresults);
645 lua_lock(L);
646 api_checknelems(L, nresults);
647 if (L->nny > 0) {
648 if (L != G(L)->mainthread)
649 luaG_runerror(L, "attempt to yield across a C-call boundary");
650 else
651 luaG_runerror(L, "attempt to yield from outside a coroutine");
652 }
653 L->status = LUA_YIELD;
654 ci->extra = savestack(L, ci->func); /* save current 'func' */
655 if (isLua(ci)) { /* inside a hook? */
656 api_check(L, k == NULL, "hooks cannot continue after yielding");
657 }
658 else {
659 if ((ci->u.c.k = k) != NULL) /* is there a continuation? */
660 ci->u.c.ctx = ctx; /* save context */
661 ci->func = L->top - nresults - 1; /* protect stack below results */
662 luaD_throw(L, LUA_YIELD);
663 }
664 lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */
665 lua_unlock(L);
666 return 0; /* return to 'luaD_hook' */
667}
668
669
670int luaD_pcall (lua_State *L, Pfunc func, void *u,

Callers

nothing calls this directly

Calls 2

luaG_runerrorFunction · 0.70
luaD_throwFunction · 0.70

Tested by

no test coverage detected