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

Function luaB_costatus

depends/lua/src/lcorolib.c:111–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109
110
111static int luaB_costatus (lua_State *L) {
112 lua_State *co = getco(L);
113 if (L == co) lua_pushliteral(L, "running");
114 else {
115 switch (lua_status(co)) {
116 case LUA_YIELD:
117 lua_pushliteral(L, "suspended");
118 break;
119 case LUA_OK: {
120 lua_Debug ar;
121 if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
122 lua_pushliteral(L, "normal"); /* it is running */
123 else if (lua_gettop(co) == 0)
124 lua_pushliteral(L, "dead");
125 else
126 lua_pushliteral(L, "suspended"); /* initial state */
127 break;
128 }
129 default: /* some error occurred */
130 lua_pushliteral(L, "dead");
131 break;
132 }
133 }
134 return 1;
135}
136
137
138static int luaB_yieldable (lua_State *L) {

Callers

nothing calls this directly

Calls 4

getcoFunction · 0.85
lua_statusFunction · 0.85
lua_getstackFunction · 0.85
lua_gettopFunction · 0.85

Tested by

no test coverage detected