Lines Matching full:l

59   lua_State l;  member
67 LX l; member
73 #define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) argument
85 static unsigned int makeseed (lua_State *L) { in makeseed() argument
89 addbuff(buff, p, L); /* heap variable */ in makeseed()
108 CallInfo *luaE_extendCI (lua_State *L) { in luaE_extendCI() argument
109 CallInfo *ci = luaM_new(L, CallInfo); in luaE_extendCI()
110 lua_assert(L->ci->next == NULL); in luaE_extendCI()
111 L->ci->next = ci; in luaE_extendCI()
112 ci->previous = L->ci; in luaE_extendCI()
118 void luaE_freeCI (lua_State *L) { in luaE_freeCI() argument
119 CallInfo *ci = L->ci; in luaE_freeCI()
124 luaM_free(L, ci); in luaE_freeCI()
129 static void stack_init (lua_State *L1, lua_State *L) { in stack_init() argument
132 L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); in stack_init()
149 static void freestack (lua_State *L) { in freestack() argument
150 if (L->stack == NULL) in freestack()
152 L->ci = &L->base_ci; /* free the entire 'ci' list */ in freestack()
153 luaE_freeCI(L); in freestack()
154 luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ in freestack()
161 static void init_registry (lua_State *L, global_State *g) { in init_registry() argument
164 Table *registry = luaH_new(L); in init_registry()
165 sethvalue(L, &g->l_registry, registry); in init_registry()
166 luaH_resize(L, registry, LUA_RIDX_LAST, 0); in init_registry()
167 /* registry[LUA_RIDX_MAINTHREAD] = L */ in init_registry()
168 setthvalue(L, &mt, L); in init_registry()
169 luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt); in init_registry()
171 sethvalue(L, &mt, luaH_new(L)); in init_registry()
172 luaH_setint(L, registry, LUA_RIDX_GLOBALS, &mt); in init_registry()
179 static void f_luaopen (lua_State *L, void *ud) { in f_luaopen() argument
180 global_State *g = G(L); in f_luaopen()
182 stack_init(L, L); /* init stack */ in f_luaopen()
183 init_registry(L, g); in f_luaopen()
184 luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ in f_luaopen()
185 luaT_init(L); in f_luaopen()
186 luaX_init(L); in f_luaopen()
188 g->memerrmsg = luaS_newliteral(L, MEMERRMSG); in f_luaopen()
192 luai_userstateopen(L); in f_luaopen()
200 static void preinit_state (lua_State *L, global_State *g) { in preinit_state() argument
201 G(L) = g; in preinit_state()
202 L->stack = NULL; in preinit_state()
203 L->ci = NULL; in preinit_state()
204 L->stacksize = 0; in preinit_state()
205 L->errorJmp = NULL; in preinit_state()
206 L->nCcalls = 0; in preinit_state()
207 L->hook = NULL; in preinit_state()
208 L->hookmask = 0; in preinit_state()
209 L->basehookcount = 0; in preinit_state()
210 L->allowhook = 1; in preinit_state()
211 resethookcount(L); in preinit_state()
212 L->openupval = NULL; in preinit_state()
213 L->nny = 1; in preinit_state()
214 L->status = LUA_OK; in preinit_state()
215 L->errfunc = 0; in preinit_state()
216 L->runerror = 0; in preinit_state()
220 static void close_state (lua_State *L) { in close_state() argument
221 global_State *g = G(L); in close_state()
222 luaF_close(L, L->stack); /* close all upvalues for this thread */ in close_state()
223 luaC_freeallobjects(L); /* collect all objects */ in close_state()
225 luai_userstateclose(L); in close_state()
226 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); in close_state()
227 luaZ_freebuffer(L, &g->buff); in close_state()
228 freestack(L); in close_state()
230 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ in close_state()
234 LUA_API lua_State *lua_newthread (lua_State *L) { in lua_newthread() argument
236 lua_lock(L); in lua_newthread()
237 luaC_checkGC(L); in lua_newthread()
238 L1 = &luaC_newobj(L, LUA_TTHREAD, sizeof(LX), NULL, offsetof(LX, l))->th; in lua_newthread()
239 setthvalue(L, L->top, L1); in lua_newthread()
240 api_incr_top(L); in lua_newthread()
241 preinit_state(L1, G(L)); in lua_newthread()
242 L1->hookmask = L->hookmask; in lua_newthread()
243 L1->basehookcount = L->basehookcount; in lua_newthread()
244 L1->hook = L->hook; in lua_newthread()
246 luai_userstatethread(L, L1); in lua_newthread()
247 stack_init(L1, L); /* init stack */ in lua_newthread()
248 lua_unlock(L); in lua_newthread()
253 void luaE_freethread (lua_State *L, lua_State *L1) { in luaE_freethread() argument
254 LX *l = fromstate(L1); in luaE_freethread() local
257 luai_userstatefree(L, L1); in luaE_freethread()
259 luaM_free(L, l); in luaE_freethread()
265 lua_State *L; in lua_newstate() local
267 LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG))); in lua_newstate() local
268 if (l == NULL) return NULL; in lua_newstate()
269 L = &l->l.l; in lua_newstate()
270 g = &l->g; in lua_newstate()
271 L->next = NULL; in lua_newstate()
272 L->tt = LUA_TTHREAD; in lua_newstate()
274 L->marked = luaC_white(g); in lua_newstate()
276 preinit_state(L, g); in lua_newstate()
279 g->mainthread = L; in lua_newstate()
280 g->seed = makeseed(L); in lua_newstate()
281 g->uvhead.u.l.prev = &g->uvhead; in lua_newstate()
282 g->uvhead.u.l.next = &g->uvhead; in lua_newstate()
289 luaZ_initbuffer(L, &g->buff); in lua_newstate()
305 if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { in lua_newstate()
307 close_state(L); in lua_newstate()
308 L = NULL; in lua_newstate()
310 return L; in lua_newstate()
314 LUA_API void lua_close (lua_State *L) { in lua_close() argument
315 L = G(L)->mainthread; /* only the main thread can be closed */ in lua_close()
316 lua_lock(L); in lua_close()
317 close_state(L); in lua_close()