• Home
  • Raw
  • Download

Lines Matching +full:- +full:l

37   lua_State l;  member
45 LX l; member
51 #define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) argument
71 static unsigned int luai_makeseed (lua_State *L) { in luai_makeseed() argument
75 addbuff(buff, p, L); /* heap variable */ in luai_makeseed()
92 if (debt < tb - MAX_LMEM) in luaE_setdebt()
93 debt = tb - MAX_LMEM; /* will make 'totalbytes == MAX_LMEM' */ in luaE_setdebt()
94 g->totalbytes = tb - debt; in luaE_setdebt()
95 g->GCdebt = debt; in luaE_setdebt()
99 LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit) { in lua_setcstacklimit() argument
100 global_State *g = G(L); in lua_setcstacklimit()
102 luaE_freeCI(L); /* release unused CIs */ in lua_setcstacklimit()
103 ccalls = getCcalls(L); in lua_setcstacklimit()
107 if (L != g-> mainthread) in lua_setcstacklimit()
112 int diff = limit - g->Cstacklimit; in lua_setcstacklimit()
115 g->Cstacklimit = limit; /* set new limit */ in lua_setcstacklimit()
116 L->nCcalls += diff; /* correct 'nCcalls' */ in lua_setcstacklimit()
117 return limit - diff - CSTACKERR; /* success; return previous limit */ in lua_setcstacklimit()
135 void luaE_enterCcall (lua_State *L) { in luaE_enterCcall() argument
136 int ncalls = getCcalls(L); in luaE_enterCcall()
137 L->nCcalls--; in luaE_enterCcall()
139 luaE_freeCI(L); /* release unused CIs */ in luaE_enterCcall()
140 ncalls = getCcalls(L); /* update call count */ in luaE_enterCcall()
142 if (ncalls <= CSTACKERRMARK) /* below error-handling zone? */ in luaE_enterCcall()
143 luaD_throw(L, LUA_ERRERR); /* error while handling stack error */ in luaE_enterCcall()
145 /* not in error-handling zone; raise the error now */ in luaE_enterCcall()
146 L->nCcalls = (CSTACKMARK - 1); /* enter error-handling zone */ in luaE_enterCcall()
147 luaG_runerror(L, "C stack overflow"); in luaE_enterCcall()
149 /* else stack is in the error-handling zone; in luaE_enterCcall()
156 CallInfo *luaE_extendCI (lua_State *L) { in luaE_extendCI() argument
158 lua_assert(L->ci->next == NULL); in luaE_extendCI()
159 luaE_enterCcall(L); in luaE_extendCI()
160 ci = luaM_new(L, CallInfo); in luaE_extendCI()
161 lua_assert(L->ci->next == NULL); in luaE_extendCI()
162 L->ci->next = ci; in luaE_extendCI()
163 ci->previous = L->ci; in luaE_extendCI()
164 ci->next = NULL; in luaE_extendCI()
165 ci->u.l.trap = 0; in luaE_extendCI()
166 L->nci++; in luaE_extendCI()
174 void luaE_freeCI (lua_State *L) { in luaE_freeCI() argument
175 CallInfo *ci = L->ci; in luaE_freeCI()
176 CallInfo *next = ci->next; in luaE_freeCI()
177 ci->next = NULL; in luaE_freeCI()
178 L->nCcalls += L->nci; /* add removed elements back to 'nCcalls' */ in luaE_freeCI()
180 next = ci->next; in luaE_freeCI()
181 luaM_free(L, ci); in luaE_freeCI()
182 L->nci--; in luaE_freeCI()
184 L->nCcalls -= L->nci; /* adjust result */ in luaE_freeCI()
192 void luaE_shrinkCI (lua_State *L) { in luaE_shrinkCI() argument
193 CallInfo *ci = L->ci->next; /* first free CallInfo */ in luaE_shrinkCI()
197 L->nCcalls += L->nci; /* add removed elements back to 'nCcalls' */ in luaE_shrinkCI()
198 while ((next = ci->next) != NULL) { /* two extra elements? */ in luaE_shrinkCI()
199 CallInfo *next2 = next->next; /* next's next */ in luaE_shrinkCI()
200 ci->next = next2; /* remove next from the list */ in luaE_shrinkCI()
201 L->nci--; in luaE_shrinkCI()
202 luaM_free(L, next); /* free next */ in luaE_shrinkCI()
206 next2->previous = ci; in luaE_shrinkCI()
210 L->nCcalls -= L->nci; /* adjust result */ in luaE_shrinkCI()
214 static void stack_init (lua_State *L1, lua_State *L) { in stack_init() argument
217 L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, StackValue); in stack_init()
218 L1->stacksize = BASIC_STACK_SIZE; in stack_init()
220 setnilvalue(s2v(L1->stack + i)); /* erase new stack */ in stack_init()
221 L1->top = L1->stack; in stack_init()
222 L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; in stack_init()
224 ci = &L1->base_ci; in stack_init()
225 ci->next = ci->previous = NULL; in stack_init()
226 ci->callstatus = CIST_C; in stack_init()
227 ci->func = L1->top; in stack_init()
228 ci->u.c.k = NULL; in stack_init()
229 ci->nresults = 0; in stack_init()
230 setnilvalue(s2v(L1->top)); /* 'function' entry for this 'ci' */ in stack_init()
231 L1->top++; in stack_init()
232 ci->top = L1->top + LUA_MINSTACK; in stack_init()
233 L1->ci = ci; in stack_init()
237 static void freestack (lua_State *L) { in freestack() argument
238 if (L->stack == NULL) in freestack()
240 L->ci = &L->base_ci; /* free the entire 'ci' list */ in freestack()
241 luaE_freeCI(L); in freestack()
242 lua_assert(L->nci == 0); in freestack()
243 luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ in freestack()
250 static void init_registry (lua_State *L, global_State *g) { in init_registry() argument
253 Table *registry = luaH_new(L); in init_registry()
254 sethvalue(L, &g->l_registry, registry); in init_registry()
255 luaH_resize(L, registry, LUA_RIDX_LAST, 0); in init_registry()
256 /* registry[LUA_RIDX_MAINTHREAD] = L */ in init_registry()
257 setthvalue(L, &temp, L); /* temp = L */ in init_registry()
258 luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); in init_registry()
260 sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ in init_registry()
261 luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); in init_registry()
266 ** open parts of the state that may cause memory-allocation errors.
267 ** ('g->nilvalue' being a nil value flags that the state was completely
270 static void f_luaopen (lua_State *L, void *ud) { in f_luaopen() argument
271 global_State *g = G(L); in f_luaopen()
273 stack_init(L, L); /* init stack */ in f_luaopen()
274 init_registry(L, g); in f_luaopen()
275 luaS_init(L); in f_luaopen()
276 luaT_init(L); in f_luaopen()
277 luaX_init(L); in f_luaopen()
278 g->gcrunning = 1; /* allow gc */ in f_luaopen()
279 setnilvalue(&g->nilvalue); in f_luaopen()
280 luai_userstateopen(L); in f_luaopen()
288 static void preinit_thread (lua_State *L, global_State *g) { in preinit_thread() argument
289 G(L) = g; in preinit_thread()
290 L->stack = NULL; in preinit_thread()
291 L->ci = NULL; in preinit_thread()
292 L->nci = 0; in preinit_thread()
293 L->stacksize = 0; in preinit_thread()
294 L->twups = L; /* thread has no upvalues */ in preinit_thread()
295 L->errorJmp = NULL; in preinit_thread()
296 L->hook = NULL; in preinit_thread()
297 L->hookmask = 0; in preinit_thread()
298 L->basehookcount = 0; in preinit_thread()
299 L->allowhook = 1; in preinit_thread()
300 resethookcount(L); in preinit_thread()
301 L->openupval = NULL; in preinit_thread()
302 L->status = LUA_OK; in preinit_thread()
303 L->errfunc = 0; in preinit_thread()
304 L->oldpc = 0; in preinit_thread()
308 static void close_state (lua_State *L) { in close_state() argument
309 global_State *g = G(L); in close_state()
310 luaF_close(L, L->stack, CLOSEPROTECT); /* close all upvalues */ in close_state()
311 luaC_freeallobjects(L); /* collect all objects */ in close_state()
312 if (ttisnil(&g->nilvalue)) /* closing a fully built state? */ in close_state()
313 luai_userstateclose(L); in close_state()
314 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); in close_state()
315 freestack(L); in close_state()
317 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ in close_state()
321 LUA_API lua_State *lua_newthread (lua_State *L) { in lua_newthread() argument
324 lua_lock(L); in lua_newthread()
325 g = G(L); in lua_newthread()
326 luaC_checkGC(L); in lua_newthread()
328 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; in lua_newthread()
329 L1->marked = luaC_white(g); in lua_newthread()
330 L1->tt = LUA_VTHREAD; in lua_newthread()
332 L1->next = g->allgc; in lua_newthread()
333 g->allgc = obj2gco(L1); in lua_newthread()
334 /* anchor it on L stack */ in lua_newthread()
335 setthvalue2s(L, L->top, L1); in lua_newthread()
336 api_incr_top(L); in lua_newthread()
338 L1->nCcalls = getCcalls(L); in lua_newthread()
339 L1->hookmask = L->hookmask; in lua_newthread()
340 L1->basehookcount = L->basehookcount; in lua_newthread()
341 L1->hook = L->hook; in lua_newthread()
344 memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread), in lua_newthread()
346 luai_userstatethread(L, L1); in lua_newthread()
347 stack_init(L1, L); /* init stack */ in lua_newthread()
348 lua_unlock(L); in lua_newthread()
353 void luaE_freethread (lua_State *L, lua_State *L1) { in luaE_freethread() argument
354 LX *l = fromstate(L1); in luaE_freethread() local
355 luaF_close(L1, L1->stack, NOCLOSINGMETH); /* close all upvalues */ in luaE_freethread()
356 lua_assert(L1->openupval == NULL); in luaE_freethread()
357 luai_userstatefree(L, L1); in luaE_freethread()
359 luaM_free(L, l); in luaE_freethread()
363 int lua_resetthread (lua_State *L) { in lua_resetthread() argument
366 lua_lock(L); in lua_resetthread()
367 L->ci = ci = &L->base_ci; /* unwind CallInfo list */ in lua_resetthread()
368 setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */ in lua_resetthread()
369 ci->func = L->stack; in lua_resetthread()
370 ci->callstatus = CIST_C; in lua_resetthread()
371 status = luaF_close(L, L->stack, CLOSEPROTECT); in lua_resetthread()
373 luaD_seterrorobj(L, status, L->stack + 1); in lua_resetthread()
376 L->top = L->stack + 1; in lua_resetthread()
378 ci->top = L->top + LUA_MINSTACK; in lua_resetthread()
379 L->status = status; in lua_resetthread()
380 lua_unlock(L); in lua_resetthread()
387 lua_State *L; in lua_newstate() local
389 LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG))); in lua_newstate() local
390 if (l == NULL) return NULL; in lua_newstate()
391 L = &l->l.l; in lua_newstate()
392 g = &l->g; in lua_newstate()
393 L->tt = LUA_VTHREAD; in lua_newstate()
394 g->currentwhite = bitmask(WHITE0BIT); in lua_newstate()
395 L->marked = luaC_white(g); in lua_newstate()
396 preinit_thread(L, g); in lua_newstate()
397 g->allgc = obj2gco(L); /* by now, only object is the main thread */ in lua_newstate()
398 L->next = NULL; in lua_newstate()
399 g->Cstacklimit = L->nCcalls = LUAI_MAXCSTACK + CSTACKERR; in lua_newstate()
400 incnny(L); /* main thread is always non yieldable */ in lua_newstate()
401 g->frealloc = f; in lua_newstate()
402 g->ud = ud; in lua_newstate()
403 g->warnf = NULL; in lua_newstate()
404 g->ud_warn = NULL; in lua_newstate()
405 g->mainthread = L; in lua_newstate()
406 g->seed = luai_makeseed(L); in lua_newstate()
407 g->gcrunning = 0; /* no GC while building state */ in lua_newstate()
408 g->strt.size = g->strt.nuse = 0; in lua_newstate()
409 g->strt.hash = NULL; in lua_newstate()
410 setnilvalue(&g->l_registry); in lua_newstate()
411 g->panic = NULL; in lua_newstate()
412 g->gcstate = GCSpause; in lua_newstate()
413 g->gckind = KGC_INC; in lua_newstate()
414 g->gcemergency = 0; in lua_newstate()
415 g->finobj = g->tobefnz = g->fixedgc = NULL; in lua_newstate()
416 g->firstold1 = g->survival = g->old1 = g->reallyold = NULL; in lua_newstate()
417 g->finobjsur = g->finobjold1 = g->finobjrold = NULL; in lua_newstate()
418 g->sweepgc = NULL; in lua_newstate()
419 g->gray = g->grayagain = NULL; in lua_newstate()
420 g->weak = g->ephemeron = g->allweak = NULL; in lua_newstate()
421 g->twups = NULL; in lua_newstate()
422 g->totalbytes = sizeof(LG); in lua_newstate()
423 g->GCdebt = 0; in lua_newstate()
424 g->lastatomic = 0; in lua_newstate()
425 setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */ in lua_newstate()
426 setgcparam(g->gcpause, LUAI_GCPAUSE); in lua_newstate()
427 setgcparam(g->gcstepmul, LUAI_GCMUL); in lua_newstate()
428 g->gcstepsize = LUAI_GCSTEPSIZE; in lua_newstate()
429 setgcparam(g->genmajormul, LUAI_GENMAJORMUL); in lua_newstate()
430 g->genminormul = LUAI_GENMINORMUL; in lua_newstate()
431 for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; in lua_newstate()
432 if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { in lua_newstate()
434 close_state(L); in lua_newstate()
435 L = NULL; in lua_newstate()
437 return L; in lua_newstate()
441 LUA_API void lua_close (lua_State *L) { in lua_close() argument
442 lua_lock(L); in lua_close()
443 L = G(L)->mainthread; /* only the main thread can be closed */ in lua_close()
444 close_state(L); in lua_close()
448 void luaE_warning (lua_State *L, const char *msg, int tocont) { in luaE_warning() argument
449 lua_WarnFunction wf = G(L)->warnf; in luaE_warning()
451 wf(G(L)->ud_warn, msg, tocont); in luaE_warning()
458 void luaE_warnerror (lua_State *L, const char *where) { in luaE_warnerror() argument
459 TValue *errobj = s2v(L->top - 1); /* error object */ in luaE_warnerror()
464 luaE_warning(L, "error in ", 1); in luaE_warnerror()
465 luaE_warning(L, where, 1); in luaE_warnerror()
466 luaE_warning(L, " (", 1); in luaE_warnerror()
467 luaE_warning(L, msg, 1); in luaE_warnerror()
468 luaE_warning(L, ")", 0); in luaE_warnerror()