Lines Matching refs:L

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()
99 LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit) { in lua_setcstacklimit() argument
100 UNUSED(L); UNUSED(limit); in lua_setcstacklimit()
105 CallInfo *luaE_extendCI (lua_State *L) { in luaE_extendCI() argument
107 lua_assert(L->ci->next == NULL); in luaE_extendCI()
108 ci = luaM_new(L, CallInfo); in luaE_extendCI()
109 lua_assert(L->ci->next == NULL); in luaE_extendCI()
110 L->ci->next = ci; in luaE_extendCI()
111 ci->previous = L->ci; 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()
128 luaM_free(L, ci); in luaE_freeCI()
129 L->nci--; in luaE_freeCI()
138 void luaE_shrinkCI (lua_State *L) { in luaE_shrinkCI() argument
139 CallInfo *ci = L->ci->next; /* first free CallInfo */ in luaE_shrinkCI()
146 L->nci--; in luaE_shrinkCI()
147 luaM_free(L, next); /* free next */ in luaE_shrinkCI()
165 void luaE_checkcstack (lua_State *L) { in luaE_checkcstack() argument
166 if (getCcalls(L) == LUAI_MAXCCALLS) in luaE_checkcstack()
167 luaG_runerror(L, "C stack overflow"); in luaE_checkcstack()
168 else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11)) in luaE_checkcstack()
169 luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ in luaE_checkcstack()
173 LUAI_FUNC void luaE_incCstack (lua_State *L) { in luaE_incCstack() argument
174 L->nCcalls++; in luaE_incCstack()
175 if (unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) in luaE_incCstack()
176 luaE_checkcstack(L); in luaE_incCstack()
180 static void stack_init (lua_State *L1, lua_State *L) { in stack_init() argument
183 L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue); in stack_init()
202 static void freestack (lua_State *L) { in freestack() argument
203 if (L->stack == NULL) in freestack()
205 L->ci = &L->base_ci; /* free the entire 'ci' list */ in freestack()
206 luaE_freeCI(L); in freestack()
207 lua_assert(L->nci == 0); in freestack()
208 luaM_freearray(L, L->stack, stacksize(L) + EXTRA_STACK); /* free stack */ in freestack()
215 static void init_registry (lua_State *L, global_State *g) { in init_registry() argument
218 Table *registry = luaH_new(L); in init_registry()
219 sethvalue(L, &g->l_registry, registry); in init_registry()
220 luaH_resize(L, registry, LUA_RIDX_LAST, 0); in init_registry()
222 setthvalue(L, &temp, L); /* temp = L */ in init_registry()
223 luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); in init_registry()
225 sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ in init_registry()
226 luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); in init_registry()
235 static void f_luaopen (lua_State *L, void *ud) { in f_luaopen() argument
236 global_State *g = G(L); in f_luaopen()
238 stack_init(L, L); /* init stack */ in f_luaopen()
239 init_registry(L, g); in f_luaopen()
240 luaS_init(L); in f_luaopen()
241 luaT_init(L); in f_luaopen()
242 luaX_init(L); in f_luaopen()
245 luai_userstateopen(L); in f_luaopen()
253 static void preinit_thread (lua_State *L, global_State *g) { in preinit_thread() argument
254 G(L) = g; in preinit_thread()
255 L->stack = NULL; in preinit_thread()
256 L->ci = NULL; in preinit_thread()
257 L->nci = 0; in preinit_thread()
258 L->twups = L; /* thread has no upvalues */ in preinit_thread()
259 L->errorJmp = NULL; in preinit_thread()
260 L->hook = NULL; in preinit_thread()
261 L->hookmask = 0; in preinit_thread()
262 L->basehookcount = 0; in preinit_thread()
263 L->allowhook = 1; in preinit_thread()
264 resethookcount(L); in preinit_thread()
265 L->openupval = NULL; in preinit_thread()
266 L->status = LUA_OK; in preinit_thread()
267 L->errfunc = 0; in preinit_thread()
268 L->oldpc = 0; in preinit_thread()
272 static void close_state (lua_State *L) { in close_state() argument
273 global_State *g = G(L); in close_state()
274 luaF_close(L, L->stack, CLOSEPROTECT); /* close all upvalues */ in close_state()
275 luaC_freeallobjects(L); /* collect all objects */ in close_state()
277 luai_userstateclose(L); in close_state()
278 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); in close_state()
279 freestack(L); in close_state()
281 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ in close_state()
285 LUA_API lua_State *lua_newthread (lua_State *L) { in lua_newthread() argument
288 lua_lock(L); in lua_newthread()
289 g = G(L); in lua_newthread()
290 luaC_checkGC(L); in lua_newthread()
292 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; in lua_newthread()
299 setthvalue2s(L, L->top, L1); in lua_newthread()
300 api_incr_top(L); in lua_newthread()
303 L1->hookmask = L->hookmask; in lua_newthread()
304 L1->basehookcount = L->basehookcount; in lua_newthread()
305 L1->hook = L->hook; in lua_newthread()
310 luai_userstatethread(L, L1); in lua_newthread()
311 stack_init(L1, L); /* init stack */ in lua_newthread()
312 lua_unlock(L); in lua_newthread()
317 void luaE_freethread (lua_State *L, lua_State *L1) { in luaE_freethread() argument
321 luai_userstatefree(L, L1); in luaE_freethread()
323 luaM_free(L, l); in luaE_freethread()
327 int lua_resetthread (lua_State *L) { in lua_resetthread() argument
330 lua_lock(L); in lua_resetthread()
331 L->ci = ci = &L->base_ci; /* unwind CallInfo list */ in lua_resetthread()
332 setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */ in lua_resetthread()
333 ci->func = L->stack; in lua_resetthread()
335 status = luaF_close(L, L->stack, CLOSEPROTECT); in lua_resetthread()
337 luaD_seterrorobj(L, status, L->stack + 1); in lua_resetthread()
340 L->top = L->stack + 1; in lua_resetthread()
342 ci->top = L->top + LUA_MINSTACK; in lua_resetthread()
343 L->status = status; in lua_resetthread()
344 lua_unlock(L); in lua_resetthread()
351 lua_State *L; in lua_newstate() local
355 L = &l->l.l; in lua_newstate()
357 L->tt = LUA_VTHREAD; in lua_newstate()
359 L->marked = luaC_white(g); in lua_newstate()
360 preinit_thread(L, g); in lua_newstate()
361 g->allgc = obj2gco(L); /* by now, only object is the main thread */ in lua_newstate()
362 L->next = NULL; in lua_newstate()
363 L->nCcalls = 0; in lua_newstate()
364 incnny(L); /* main thread is always non yieldable */ in lua_newstate()
369 g->mainthread = L; in lua_newstate()
370 g->seed = luai_makeseed(L); in lua_newstate()
396 if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { in lua_newstate()
398 close_state(L); in lua_newstate()
399 L = NULL; in lua_newstate()
401 return L; in lua_newstate()
405 LUA_API void lua_close (lua_State *L) { in lua_close() argument
406 lua_lock(L); in lua_close()
407 L = G(L)->mainthread; /* only the main thread can be closed */ in lua_close()
408 close_state(L); in lua_close()
412 void luaE_warning (lua_State *L, const char *msg, int tocont) { in luaE_warning() argument
413 lua_WarnFunction wf = G(L)->warnf; in luaE_warning()
415 wf(G(L)->ud_warn, msg, tocont); in luaE_warning()
422 void luaE_warnerror (lua_State *L, const char *where) { in luaE_warnerror() argument
423 TValue *errobj = s2v(L->top - 1); /* error object */ in luaE_warnerror()
428 luaE_warning(L, "error in ", 1); in luaE_warnerror()
429 luaE_warning(L, where, 1); in luaE_warnerror()
430 luaE_warning(L, " (", 1); in luaE_warnerror()
431 luaE_warning(L, msg, 1); in luaE_warnerror()
432 luaE_warning(L, ")", 0); in luaE_warnerror()