Lines Matching +full:- +full:l

56   lua_State l;  member
64 LX l; member
70 #define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) argument
81 static unsigned int makeseed (lua_State *L) { in makeseed() argument
85 addbuff(buff, p, L); /* heap variable */ in makeseed()
101 if (debt < tb - MAX_LMEM) in luaE_setdebt()
102 debt = tb - MAX_LMEM; /* will make 'totalbytes == MAX_LMEM' */ in luaE_setdebt()
103 g->totalbytes = tb - debt; in luaE_setdebt()
104 g->GCdebt = debt; in luaE_setdebt()
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()
113 ci->next = NULL; in luaE_extendCI()
114 L->nci++; in luaE_extendCI()
122 void luaE_freeCI (lua_State *L) { in luaE_freeCI() argument
123 CallInfo *ci = L->ci; in luaE_freeCI()
124 CallInfo *next = ci->next; in luaE_freeCI()
125 ci->next = NULL; in luaE_freeCI()
127 next = ci->next; in luaE_freeCI()
128 luaM_free(L, ci); in luaE_freeCI()
129 L->nci--; in luaE_freeCI()
137 void luaE_shrinkCI (lua_State *L) { in luaE_shrinkCI() argument
138 CallInfo *ci = L->ci; in luaE_shrinkCI()
141 while (ci->next != NULL && (next2 = ci->next->next) != NULL) { in luaE_shrinkCI()
142 luaM_free(L, ci->next); /* free next */ in luaE_shrinkCI()
143 L->nci--; in luaE_shrinkCI()
144 ci->next = next2; /* remove 'next' from the list */ in luaE_shrinkCI()
145 next2->previous = ci; in luaE_shrinkCI()
151 static void stack_init (lua_State *L1, lua_State *L) { in stack_init() argument
154 L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); in stack_init()
155 L1->stacksize = BASIC_STACK_SIZE; in stack_init()
157 setnilvalue(L1->stack + i); /* erase new stack */ in stack_init()
158 L1->top = L1->stack; in stack_init()
159 L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; in stack_init()
161 ci = &L1->base_ci; in stack_init()
162 ci->next = ci->previous = NULL; in stack_init()
163 ci->callstatus = 0; in stack_init()
164 ci->func = L1->top; in stack_init()
165 setnilvalue(L1->top++); /* 'function' entry for this 'ci' */ in stack_init()
166 ci->top = L1->top + LUA_MINSTACK; in stack_init()
167 L1->ci = ci; in stack_init()
171 static void freestack (lua_State *L) { in freestack() argument
172 if (L->stack == NULL) in freestack()
174 L->ci = &L->base_ci; /* free the entire 'ci' list */ in freestack()
175 luaE_freeCI(L); in freestack()
176 lua_assert(L->nci == 0); in freestack()
177 luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ in freestack()
184 static void init_registry (lua_State *L, global_State *g) { in init_registry() argument
187 Table *registry = luaH_new(L); in init_registry()
188 sethvalue(L, &g->l_registry, registry); in init_registry()
189 luaH_resize(L, registry, LUA_RIDX_LAST, 0); in init_registry()
190 /* registry[LUA_RIDX_MAINTHREAD] = L */ in init_registry()
191 setthvalue(L, &temp, L); /* temp = L */ in init_registry()
192 luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); in init_registry()
194 sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ in init_registry()
195 luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); in init_registry()
200 ** open parts of the state that may cause memory-allocation errors.
201 ** ('g->version' != NULL flags that the state was completely build)
203 static void f_luaopen (lua_State *L, void *ud) { in f_luaopen() argument
204 global_State *g = G(L); in f_luaopen()
206 stack_init(L, L); /* init stack */ in f_luaopen()
207 init_registry(L, g); in f_luaopen()
208 luaS_init(L); in f_luaopen()
209 luaT_init(L); in f_luaopen()
210 luaX_init(L); in f_luaopen()
211 g->gcrunning = 1; /* allow gc */ in f_luaopen()
212 g->version = lua_version(NULL); in f_luaopen()
213 luai_userstateopen(L); in f_luaopen()
221 static void preinit_thread (lua_State *L, global_State *g) { in preinit_thread() argument
222 G(L) = g; in preinit_thread()
223 L->stack = NULL; in preinit_thread()
224 L->ci = NULL; in preinit_thread()
225 L->nci = 0; in preinit_thread()
226 L->stacksize = 0; in preinit_thread()
227 L->twups = L; /* thread has no upvalues */ in preinit_thread()
228 L->errorJmp = NULL; in preinit_thread()
229 L->nCcalls = 0; in preinit_thread()
230 L->hook = NULL; in preinit_thread()
231 L->hookmask = 0; in preinit_thread()
232 L->basehookcount = 0; in preinit_thread()
233 L->allowhook = 1; in preinit_thread()
234 resethookcount(L); in preinit_thread()
235 L->openupval = NULL; in preinit_thread()
236 L->nny = 1; in preinit_thread()
237 L->status = LUA_OK; in preinit_thread()
238 L->errfunc = 0; in preinit_thread()
242 static void close_state (lua_State *L) { in close_state() argument
243 global_State *g = G(L); in close_state()
244 luaF_close(L, L->stack); /* close all upvalues for this thread */ in close_state()
245 luaC_freeallobjects(L); /* collect all objects */ in close_state()
246 if (g->version) /* closing a fully built state? */ in close_state()
247 luai_userstateclose(L); in close_state()
248 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); in close_state()
249 freestack(L); in close_state()
251 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ in close_state()
255 LUA_API lua_State *lua_newthread (lua_State *L) { in lua_newthread() argument
256 global_State *g = G(L); in lua_newthread()
258 lua_lock(L); in lua_newthread()
259 luaC_checkGC(L); in lua_newthread()
261 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; in lua_newthread()
262 L1->marked = luaC_white(g); in lua_newthread()
263 L1->tt = LUA_TTHREAD; in lua_newthread()
265 L1->next = g->allgc; in lua_newthread()
266 g->allgc = obj2gco(L1); in lua_newthread()
267 /* anchor it on L stack */ in lua_newthread()
268 setthvalue(L, L->top, L1); in lua_newthread()
269 api_incr_top(L); in lua_newthread()
271 L1->hookmask = L->hookmask; in lua_newthread()
272 L1->basehookcount = L->basehookcount; in lua_newthread()
273 L1->hook = L->hook; in lua_newthread()
276 memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread), in lua_newthread()
278 luai_userstatethread(L, L1); in lua_newthread()
279 stack_init(L1, L); /* init stack */ in lua_newthread()
280 lua_unlock(L); in lua_newthread()
285 void luaE_freethread (lua_State *L, lua_State *L1) { in luaE_freethread() argument
286 LX *l = fromstate(L1); in luaE_freethread() local
287 luaF_close(L1, L1->stack); /* close all upvalues for this thread */ in luaE_freethread()
288 lua_assert(L1->openupval == NULL); in luaE_freethread()
289 luai_userstatefree(L, L1); in luaE_freethread()
291 luaM_free(L, l); in luaE_freethread()
297 lua_State *L; in lua_newstate() local
299 LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG))); in lua_newstate() local
300 if (l == NULL) return NULL; in lua_newstate()
301 L = &l->l.l; in lua_newstate()
302 g = &l->g; in lua_newstate()
303 L->next = NULL; in lua_newstate()
304 L->tt = LUA_TTHREAD; in lua_newstate()
305 g->currentwhite = bitmask(WHITE0BIT); in lua_newstate()
306 L->marked = luaC_white(g); in lua_newstate()
307 preinit_thread(L, g); in lua_newstate()
308 g->frealloc = f; in lua_newstate()
309 g->ud = ud; in lua_newstate()
310 g->mainthread = L; in lua_newstate()
311 g->seed = makeseed(L); in lua_newstate()
312 g->gcrunning = 0; /* no GC while building state */ in lua_newstate()
313 g->GCestimate = 0; in lua_newstate()
314 g->strt.size = g->strt.nuse = 0; in lua_newstate()
315 g->strt.hash = NULL; in lua_newstate()
316 setnilvalue(&g->l_registry); in lua_newstate()
317 g->panic = NULL; in lua_newstate()
318 g->version = NULL; in lua_newstate()
319 g->gcstate = GCSpause; in lua_newstate()
320 g->gckind = KGC_NORMAL; in lua_newstate()
321 g->allgc = g->finobj = g->tobefnz = g->fixedgc = NULL; in lua_newstate()
322 g->sweepgc = NULL; in lua_newstate()
323 g->gray = g->grayagain = NULL; in lua_newstate()
324 g->weak = g->ephemeron = g->allweak = NULL; in lua_newstate()
325 g->twups = NULL; in lua_newstate()
326 g->totalbytes = sizeof(LG); in lua_newstate()
327 g->GCdebt = 0; in lua_newstate()
328 g->gcfinnum = 0; in lua_newstate()
329 g->gcpause = LUAI_GCPAUSE; in lua_newstate()
330 g->gcstepmul = LUAI_GCMUL; in lua_newstate()
331 for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; in lua_newstate()
332 if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { in lua_newstate()
334 close_state(L); in lua_newstate()
335 L = NULL; in lua_newstate()
337 return L; in lua_newstate()
341 LUA_API void lua_close (lua_State *L) { in lua_close() argument
342 L = G(L)->mainthread; /* only the main thread can be closed */ in lua_close()
343 lua_lock(L); in lua_close()
344 close_state(L); in lua_close()