MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / lua_yieldk

Function lua_yieldk

third-party/lua-5.4.6/src/ldo.c:882–910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

880
881
882LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
883 lua_KFunction k) {
884 CallInfo *ci;
885 luai_userstateyield(L, nresults);
886 lua_lock(L);
887 ci = L->ci;
888 api_checknelems(L, nresults);
889 if (l_unlikely(!yieldable(L))) {
890 if (L != G(L)->mainthread)
891 luaG_runerror(L, "attempt to yield across a C-call boundary");
892 else
893 luaG_runerror(L, "attempt to yield from outside a coroutine");
894 }
895 L->status = LUA_YIELD;
896 ci->u2.nyield = nresults; /* save number of results */
897 if (isLua(ci)) { /* inside a hook? */
898 lua_assert(!isLuacode(ci));
899 api_check(L, nresults == 0, "hooks cannot yield values");
900 api_check(L, k == NULL, "hooks cannot continue after yielding");
901 }
902 else {
903 if ((ci->u.c.k = k) != NULL) /* is there a continuation? */
904 ci->u.c.ctx = ctx; /* save context */
905 luaD_throw(L, LUA_YIELD);
906 }
907 lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */
908 lua_unlock(L);
909 return 0; /* return to 'luaD_hook' */
910}
911
912
913/*

Callers

nothing calls this directly

Calls 2

luaG_runerrorFunction · 0.70
luaD_throwFunction · 0.70

Tested by

no test coverage detected