A coroutine can close itself

A call to close itself will close all its to-be-closed variables and
return to the resume that (re)started the coroutine.
This commit is contained in:
Roberto Ierusalimschy
2025-06-12 11:15:09 -03:00
parent d05fe48bfd
commit fd897027f1
6 changed files with 103 additions and 21 deletions

10
ldo.c
View File

@@ -139,6 +139,16 @@ l_noret luaD_throw (lua_State *L, TStatus errcode) {
}
l_noret luaD_throwbaselevel (lua_State *L, TStatus errcode) {
if (L->errorJmp) {
/* unroll error entries up to the first level */
while (L->errorJmp->previous != NULL)
L->errorJmp = L->errorJmp->previous;
}
luaD_throw(L, errcode);
}
TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
l_uint32 oldnCcalls = L->nCcalls;
struct lua_longjmp lj;