MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_yieldk

Function lua_yieldk

depends/lua/src/ldo.c:692–718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690
691
692LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
693 lua_KFunction k) {
694 CallInfo *ci = L->ci;
695 luai_userstateyield(L, nresults);
696 lua_lock(L);
697 api_checknelems(L, nresults);
698 if (L->nny > 0) {
699 if (L != G(L)->mainthread)
700 luaG_runerror(L, "attempt to yield across a C-call boundary");
701 else
702 luaG_runerror(L, "attempt to yield from outside a coroutine");
703 }
704 L->status = LUA_YIELD;
705 ci->extra = savestack(L, ci->func); /* save current 'func' */
706 if (isLua(ci)) { /* inside a hook? */
707 api_check(L, k == NULL, "hooks cannot continue after yielding");
708 }
709 else {
710 if ((ci->u.c.k = k) != NULL) /* is there a continuation? */
711 ci->u.c.ctx = ctx; /* save context */
712 ci->func = L->top - nresults - 1; /* protect stack below results */
713 luaD_throw(L, LUA_YIELD);
714 }
715 lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */
716 lua_unlock(L);
717 return 0; /* return to 'luaD_hook' */
718}
719
720
721int luaD_pcall (lua_State *L, Pfunc func, void *u,

Callers

nothing calls this directly

Calls 2

luaG_runerrorFunction · 0.85
luaD_throwFunction · 0.85

Tested by

no test coverage detected