Lines Matching +full:1 +full:l

21 static lua_State *getco (lua_State *L) {  in getco()  argument
22 lua_State *co = lua_tothread(L, 1); in getco()
23 luaL_argexpected(L, co, 1, "thread"); in getco()
30 ** cases or -1 for errors.
32 static int auxresume (lua_State *L, lua_State *co, int narg) { in auxresume() argument
35 lua_pushliteral(L, "too many arguments to resume"); in auxresume()
36 return -1; /* error flag */ in auxresume()
38 lua_xmove(L, co, narg); in auxresume()
39 status = lua_resume(co, L, narg, &nres); in auxresume()
41 if (l_unlikely(!lua_checkstack(L, nres + 1))) { in auxresume()
43 lua_pushliteral(L, "too many results to resume"); in auxresume()
44 return -1; /* error flag */ in auxresume()
46 lua_xmove(co, L, nres); /* move yielded values */ in auxresume()
50 lua_xmove(co, L, 1); /* move error message */ in auxresume()
51 return -1; /* error flag */ in auxresume()
56 static int luaB_coresume (lua_State *L) { in luaB_coresume() argument
57 lua_State *co = getco(L); in luaB_coresume()
59 r = auxresume(L, co, lua_gettop(L) - 1); in luaB_coresume()
61 lua_pushboolean(L, 0); in luaB_coresume()
62 lua_insert(L, -2); in luaB_coresume()
66 lua_pushboolean(L, 1); in luaB_coresume()
67 lua_insert(L, -(r + 1)); in luaB_coresume()
68 return r + 1; /* return true + 'resume' returns */ in luaB_coresume()
73 static int luaB_auxwrap (lua_State *L) { in luaB_auxwrap() argument
74 lua_State *co = lua_tothread(L, lua_upvalueindex(1)); in luaB_auxwrap()
75 int r = auxresume(L, co, lua_gettop(L)); in luaB_auxwrap()
79 stat = lua_closethread(co, L); /* close its tbc variables */ in luaB_auxwrap()
81 lua_xmove(co, L, 1); /* move error message to the caller */ in luaB_auxwrap()
84 lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ in luaB_auxwrap()
85 luaL_where(L, 1); /* add extra info, if available */ in luaB_auxwrap()
86 lua_insert(L, -2); in luaB_auxwrap()
87 lua_concat(L, 2); in luaB_auxwrap()
89 return lua_error(L); /* propagate error */ in luaB_auxwrap()
95 static int luaB_cocreate (lua_State *L) { in luaB_cocreate() argument
97 luaL_checktype(L, 1, LUA_TFUNCTION); in luaB_cocreate()
98 NL = lua_newthread(L); in luaB_cocreate()
99 lua_pushvalue(L, 1); /* move function to top */ in luaB_cocreate()
100 lua_xmove(L, NL, 1); /* move function from L to NL */ in luaB_cocreate()
101 return 1; in luaB_cocreate()
105 static int luaB_cowrap (lua_State *L) { in luaB_cowrap() argument
106 luaB_cocreate(L); in luaB_cowrap()
107 lua_pushcclosure(L, luaB_auxwrap, 1); in luaB_cowrap()
108 return 1; in luaB_cowrap()
112 static int luaB_yield (lua_State *L) { in luaB_yield() argument
113 return lua_yield(L, lua_gettop(L)); in luaB_yield()
118 #define COS_DEAD 1
127 static int auxstatus (lua_State *L, lua_State *co) { in auxstatus() argument
128 if (L == co) return COS_RUN; in auxstatus()
149 static int luaB_costatus (lua_State *L) { in luaB_costatus() argument
150 lua_State *co = getco(L); in luaB_costatus()
151 lua_pushstring(L, statname[auxstatus(L, co)]); in luaB_costatus()
152 return 1; in luaB_costatus()
156 static int luaB_yieldable (lua_State *L) { in luaB_yieldable() argument
157 lua_State *co = lua_isnone(L, 1) ? L : getco(L); in luaB_yieldable()
158 lua_pushboolean(L, lua_isyieldable(co)); in luaB_yieldable()
159 return 1; in luaB_yieldable()
163 static int luaB_corunning (lua_State *L) { in luaB_corunning() argument
164 int ismain = lua_pushthread(L); in luaB_corunning()
165 lua_pushboolean(L, ismain); in luaB_corunning()
170 static int luaB_close (lua_State *L) { in luaB_close() argument
171 lua_State *co = getco(L); in luaB_close()
172 int status = auxstatus(L, co); in luaB_close()
175 status = lua_closethread(co, L); in luaB_close()
177 lua_pushboolean(L, 1); in luaB_close()
178 return 1; in luaB_close()
181 lua_pushboolean(L, 0); in luaB_close()
182 lua_xmove(co, L, 1); /* move error message */ in luaB_close()
187 return luaL_error(L, "cannot close a %s coroutine", statname[status]); in luaB_close()
206 LUAMOD_API int luaopen_coroutine (lua_State *L) { in luaopen_coroutine() argument
207 luaL_newlib(L, co_funcs); in luaopen_coroutine()
208 return 1; in luaopen_coroutine()