Lines Matching +full:- +full:g +full:-
68 global_State g; member
73 #define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l)))
102 void luaE_setdebt (global_State *g, l_mem debt) { in luaE_setdebt() argument
103 g->totalbytes -= (debt - g->GCdebt); in luaE_setdebt()
104 g->GCdebt = debt; in luaE_setdebt()
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()
119 CallInfo *ci = L->ci; in luaE_freeCI()
120 CallInfo *next = ci->next; in luaE_freeCI()
121 ci->next = NULL; in luaE_freeCI()
123 next = ci->next; in luaE_freeCI()
132 L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); in stack_init()
133 L1->stacksize = BASIC_STACK_SIZE; in stack_init()
135 setnilvalue(L1->stack + i); /* erase new stack */ in stack_init()
136 L1->top = L1->stack; in stack_init()
137 L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; in stack_init()
139 ci = &L1->base_ci; in stack_init()
140 ci->next = ci->previous = NULL; in stack_init()
141 ci->callstatus = 0; in stack_init()
142 ci->func = L1->top; in stack_init()
143 setnilvalue(L1->top++); /* 'function' entry for this 'ci' */ in stack_init()
144 ci->top = L1->top + LUA_MINSTACK; in stack_init()
145 L1->ci = ci; in stack_init()
150 if (L->stack == NULL) in freestack()
152 L->ci = &L->base_ci; /* free the entire 'ci' list */ 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
165 sethvalue(L, &g->l_registry, registry); in init_registry()
177 ** open parts of the state that may cause memory-allocation errors
180 global_State *g = G(L); in f_luaopen() local
183 init_registry(L, g); in f_luaopen()
187 /* pre-create memory-error message */ in f_luaopen()
188 g->memerrmsg = luaS_newliteral(L, MEMERRMSG); in f_luaopen()
189 luaS_fix(g->memerrmsg); /* it should never be collected */ in f_luaopen()
190 g->gcrunning = 1; /* allow gc */ in f_luaopen()
191 g->version = lua_version(NULL); 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()
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()
221 global_State *g = G(L); in close_state() local
222 luaF_close(L, L->stack); /* close all upvalues for this thread */ in close_state()
224 if (g->version) /* closing a fully built state? */ 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()
229 lua_assert(gettotalbytes(g) == sizeof(LG)); in close_state()
230 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ in close_state()
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()
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()
255 luaF_close(L1, L1->stack); /* close all upvalues for this thread */ in luaE_freethread()
256 lua_assert(L1->openupval == NULL); in luaE_freethread()
266 global_State *g; in lua_newstate() local
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()
273 g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); in lua_newstate()
274 L->marked = luaC_white(g); in lua_newstate()
275 g->gckind = KGC_NORMAL; in lua_newstate()
276 preinit_state(L, g); in lua_newstate()
277 g->frealloc = f; in lua_newstate()
278 g->ud = ud; 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()
283 g->gcrunning = 0; /* no GC while building state */ in lua_newstate()
284 g->GCestimate = 0; in lua_newstate()
285 g->strt.size = 0; in lua_newstate()
286 g->strt.nuse = 0; in lua_newstate()
287 g->strt.hash = NULL; in lua_newstate()
288 setnilvalue(&g->l_registry); in lua_newstate()
289 luaZ_initbuffer(L, &g->buff); in lua_newstate()
290 g->panic = NULL; in lua_newstate()
291 g->version = NULL; in lua_newstate()
292 g->gcstate = GCSpause; in lua_newstate()
293 g->allgc = NULL; in lua_newstate()
294 g->finobj = NULL; in lua_newstate()
295 g->tobefnz = NULL; in lua_newstate()
296 g->sweepgc = g->sweepfin = NULL; in lua_newstate()
297 g->gray = g->grayagain = NULL; in lua_newstate()
298 g->weak = g->ephemeron = g->allweak = NULL; in lua_newstate()
299 g->totalbytes = sizeof(LG); in lua_newstate()
300 g->GCdebt = 0; in lua_newstate()
301 g->gcpause = LUAI_GCPAUSE; in lua_newstate()
302 g->gcmajorinc = LUAI_GCMAJOR; in lua_newstate()
303 g->gcstepmul = LUAI_GCMUL; in lua_newstate()
304 for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; in lua_newstate()
315 L = G(L)->mainthread; /* only the main thread can be closed */ in lua_close()