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

Function luaB_close

third-party/lua-5.5.0/src/lcorolib.c:176–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174
175
176static int luaB_close (lua_State *L) {
177 lua_State *co = getoptco(L);
178 int status = auxstatus(L, co);
179 switch (status) {
180 case COS_DEAD: case COS_YIELD: {
181 status = lua_closethread(co, L);
182 if (status == LUA_OK) {
183 lua_pushboolean(L, 1);
184 return 1;
185 }
186 else {
187 lua_pushboolean(L, 0);
188 lua_xmove(co, L, 1); /* move error message */
189 return 2;
190 }
191 }
192 case COS_NORM:
193 return luaL_error(L, "cannot close a %s coroutine", statname[status]);
194 case COS_RUN:
195 lua_geti(L, LUA_REGISTRYINDEX, LUA_RIDX_MAINTHREAD); /* get main */
196 if (lua_tothread(L, -1) == co)
197 return luaL_error(L, "cannot close main thread");
198 lua_closethread(co, L); /* close itself */
199 /* previous call does not return *//* FALLTHROUGH */
200 default:
201 lua_assert(0);
202 return 0;
203 }
204}
205
206
207static const luaL_Reg co_funcs[] = {

Callers

nothing calls this directly

Calls 8

getoptcoFunction · 0.85
auxstatusFunction · 0.70
lua_closethreadFunction · 0.70
lua_pushbooleanFunction · 0.70
lua_xmoveFunction · 0.70
luaL_errorFunction · 0.70
lua_getiFunction · 0.70
lua_tothreadFunction · 0.70

Tested by

no test coverage detected