| 100 | |
| 101 | |
| 102 | static int luaB_costatus (lua_State *L) { |
| 103 | lua_State *co = lua_tothread(L, 1); |
| 104 | luaL_argcheck(L, co, 1, "coroutine expected"); |
| 105 | if (L == co) lua_pushliteral(L, "running"); |
| 106 | else { |
| 107 | switch (lua_status(co)) { |
| 108 | case LUA_YIELD: |
| 109 | lua_pushliteral(L, "suspended"); |
| 110 | break; |
| 111 | case LUA_OK: { |
| 112 | lua_Debug ar; |
| 113 | if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ |
| 114 | lua_pushliteral(L, "normal"); /* it is running */ |
| 115 | else if (lua_gettop(co) == 0) |
| 116 | lua_pushliteral(L, "dead"); |
| 117 | else |
| 118 | lua_pushliteral(L, "suspended"); /* initial state */ |
| 119 | break; |
| 120 | } |
| 121 | default: /* some error occurred */ |
| 122 | lua_pushliteral(L, "dead"); |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | return 1; |
| 127 | } |
| 128 | |
| 129 | |
| 130 | static int luaB_corunning (lua_State *L) { |
nothing calls this directly
no test coverage detected