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

Function lua_yieldk

third-party/lua-5.2.4/src/ldo.c:567–592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565
566
567LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) {
568 CallInfo *ci = L->ci;
569 luai_userstateyield(L, nresults);
570 lua_lock(L);
571 api_checknelems(L, nresults);
572 if (L->nny > 0) {
573 if (L != G(L)->mainthread)
574 luaG_runerror(L, "attempt to yield across a C-call boundary");
575 else
576 luaG_runerror(L, "attempt to yield from outside a coroutine");
577 }
578 L->status = LUA_YIELD;
579 ci->extra = savestack(L, ci->func); /* save current 'func' */
580 if (isLua(ci)) { /* inside a hook? */
581 api_check(L, k == NULL, "hooks cannot continue after yielding");
582 }
583 else {
584 if ((ci->u.c.k = k) != NULL) /* is there a continuation? */
585 ci->u.c.ctx = ctx; /* save context */
586 ci->func = L->top - nresults - 1; /* protect stack below results */
587 luaD_throw(L, LUA_YIELD);
588 }
589 lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */
590 lua_unlock(L);
591 return 0; /* return to 'luaD_hook' */
592}
593
594
595int 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