Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lstate.c File Reference
#include "lprefix.h"
#include <stddef.h>
#include <string.h>
#include "lua.h"
#include "lapi.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
#include "llex.h"
#include "lmem.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "ltm.h"
#include <time.h>

Go to the source code of this file.

Data Structures

struct  LX
 
struct  LG
 

Macros

#define lstate_c
 
#define LUA_CORE
 
#define fromstate(L)   (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l)))
 
#define addbuff(b, p, e)
 

Typedefs

typedef struct LX LX
 
typedef struct LG LG
 

Functions

static unsigned int luai_makeseed (lua_State *L)
 
void luaE_setdebt (global_State *g, l_mem debt)
 
LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit)
 
CallInfoluaE_extendCI (lua_State *L)
 
void luaE_freeCI (lua_State *L)
 
void luaE_shrinkCI (lua_State *L)
 
void luaE_checkcstack (lua_State *L)
 
LUAI_FUNC void luaE_incCstack (lua_State *L)
 
static void stack_init (lua_State *L1, lua_State *L)
 
static void freestack (lua_State *L)
 
static void init_registry (lua_State *L, global_State *g)
 
static void f_luaopen (lua_State *L, void *ud)
 
static void preinit_thread (lua_State *L, global_State *g)
 
static void close_state (lua_State *L)
 
LUA_API lua_Statelua_newthread (lua_State *L)
 
void luaE_freethread (lua_State *L, lua_State *L1)
 
int luaE_resetthread (lua_State *L, int status)
 
LUA_API int lua_resetthread (lua_State *L)
 
LUA_API lua_Statelua_newstate (lua_Alloc f, void *ud)
 
LUA_API void lua_close (lua_State *L)
 
void luaE_warning (lua_State *L, const char *msg, int tocont)
 
void luaE_warnerror (lua_State *L, const char *where)
 

Macro Definition Documentation

◆ addbuff

#define addbuff ( b,
p,
e )
Value:
{ size_t t = cast_sizet(e); \
memcpy(b + p, &t, sizeof(t)); p += sizeof(t); }
#define cast_sizet(i)

Definition at line 67 of file lua-5.4.3/src/lstate.c.

67#define addbuff(b,p,e) \
68 { size_t t = cast_sizet(e); \
69 memcpy(b + p, &t, sizeof(t)); p += sizeof(t); }

Referenced by luai_makeseed().

◆ fromstate

#define fromstate ( L)    (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l)))

Definition at line 51 of file lua-5.4.3/src/lstate.c.

Referenced by close_state(), and luaE_freethread().

◆ lstate_c

#define lstate_c

Definition at line 7 of file lua-5.4.3/src/lstate.c.

◆ LUA_CORE

#define LUA_CORE

Definition at line 8 of file lua-5.4.3/src/lstate.c.

Typedef Documentation

◆ LG

typedef struct LG LG

◆ LX

typedef struct LX LX

Function Documentation

◆ close_state()

static void close_state ( lua_State * L)
static

Definition at line 269 of file lua-5.4.3/src/lstate.c.

269 {
270 global_State *g = G(L);
271 if (!completestate(g)) /* closing a partially built state? */
272 luaC_freeallobjects(L); /* jucst collect its objects */
273 else { /* closing a fully built state */
274 luaD_closeprotected(L, 1, LUA_OK); /* close all upvalues */
275 luaC_freeallobjects(L); /* collect all objects */
277 }
278 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size);
279 freestack(L);
280 lua_assert(gettotalbytes(g) == sizeof(LG));
281 (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */
282}
#define lua_assert(c)
#define luaM_freearray(L, b, n, t)
#define G(L)
#define luai_userstateclose(L)
void luaC_freeallobjects(lua_State *L)
#define gettotalbytes(g)
#define LUA_OK
int luaD_closeprotected(lua_State *L, ptrdiff_t level, int status)
#define fromstate(L)
static void freestack(lua_State *L)
struct LG LG
#define completestate(g)

References completestate, global_State::frealloc, freestack(), fromstate, G, gettotalbytes, lua_assert, LUA_OK, luaC_freeallobjects(), luaD_closeprotected(), luai_userstateclose, luaM_freearray, and global_State::ud.

Referenced by lua_close(), and lua_newstate().

◆ f_luaopen()

static void f_luaopen ( lua_State * L,
void * ud )
static

Definition at line 231 of file lua-5.4.3/src/lstate.c.

231 {
232 global_State *g = G(L);
233 UNUSED(ud);
234 stack_init(L, L); /* init stack */
235 init_registry(L, g);
236 luaS_init(L);
237 luaT_init(L);
238 luaX_init(L);
239 g->gcrunning = 1; /* allow gc */
240 setnilvalue(&g->nilvalue); /* now state is complete */
242}
#define UNUSED(x)
#define setnilvalue(obj)
void luaT_init(lua_State *L)
#define luai_userstateopen(L)
void luaS_init(lua_State *L)
static void init_registry(lua_State *L, global_State *g)
static void stack_init(lua_State *L1, lua_State *L)
LUAI_FUNC void luaX_init(lua_State *L)
Definition noparser.c:21

References G, global_State::gcrunning, init_registry(), luai_userstateopen, luaS_init(), luaT_init(), luaX_init(), global_State::nilvalue, setnilvalue, stack_init(), and UNUSED.

Referenced by lua_newstate().

◆ freestack()

static void freestack ( lua_State * L)
static

Definition at line 203 of file lua-5.4.3/src/lstate.c.

203 {
204 if (L->stack == NULL)
205 return; /* stack not completely built yet */
206 L->ci = &L->base_ci; /* free the entire 'ci' list */
207 luaE_freeCI(L);
208 lua_assert(L->nci == 0);
209 luaM_freearray(L, L->stack, stacksize(L) + EXTRA_STACK); /* free stack */
210}
#define NULL
Definition gmacros.h:924
#define EXTRA_STACK
void luaE_freeCI(lua_State *L)
#define stacksize(th)
unsigned short nci

References lua_State::base_ci, lua_State::ci, EXTRA_STACK, lua_assert, luaE_freeCI(), luaM_freearray, lua_State::nci, NULL, lua_State::stack, and stacksize.

Referenced by close_state(), and luaE_freethread().

◆ init_registry()

static void init_registry ( lua_State * L,
global_State * g )
static

Definition at line 216 of file lua-5.4.3/src/lstate.c.

216 {
217 /* create registry */
218 Table *registry = luaH_new(L);
221 /* registry[LUA_RIDX_MAINTHREAD] = L */
222 setthvalue(L, &registry->array[LUA_RIDX_MAINTHREAD - 1], L);
223 /* registry[LUA_RIDX_GLOBALS] = new table (table of globals) */
224 sethvalue(L, &registry->array[LUA_RIDX_GLOBALS - 1], luaH_new(L));
225}
#define setthvalue(L, obj, x)
#define sethvalue(L, obj, x)
#define registry(L)
Table * luaH_new(lua_State *L, int narray, int nhash)
void luaH_resize(lua_State *L, Table *t, int nasize, int nhsize)
#define LUA_RIDX_GLOBALS
#define LUA_RIDX_LAST
#define LUA_RIDX_MAINTHREAD

References global_State::l_registry, LUA_RIDX_GLOBALS, LUA_RIDX_LAST, LUA_RIDX_MAINTHREAD, luaH_new(), luaH_resize(), registry, sethvalue, and setthvalue.

Referenced by f_luaopen().

◆ lua_close()

LUA_API void lua_close ( lua_State * L)

Definition at line 410 of file lua-5.4.3/src/lstate.c.

410 {
411 lua_lock(L);
412 L = G(L)->mainthread; /* only the main thread can be closed */
413 close_state(L);
414}
#define lua_lock(L)
static void close_state(lua_State *L)

References close_state(), G, and lua_lock.

◆ lua_newstate()

LUA_API lua_State * lua_newstate ( lua_Alloc f,
void * ud )

Definition at line 354 of file lua-5.4.3/src/lstate.c.

354 {
355 int i;
356 lua_State *L;
357 global_State *g;
358 LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG)));
359 if (l == NULL) return NULL;
360 L = &l->l.l;
361 g = &l->g;
362 L->tt = LUA_VTHREAD;
364 L->marked = luaC_white(g);
365 preinit_thread(L, g);
366 g->allgc = obj2gco(L); /* by now, only object is the main thread */
367 L->next = NULL;
368 incnny(L); /* main thread is always non yieldable */
369 g->frealloc = f;
370 g->ud = ud;
371 g->warnf = NULL;
372 g->ud_warn = NULL;
373 g->mainthread = L;
374 g->seed = luai_makeseed(L);
375 g->gcrunning = 0; /* no GC while building state */
376 g->strt.size = g->strt.nuse = 0;
377 g->strt.hash = NULL;
379 g->panic = NULL;
380 g->gcstate = GCSpause;
381 g->gckind = KGC_INC;
382 g->gcstopem = 0;
383 g->gcemergency = 0;
384 g->finobj = g->tobefnz = g->fixedgc = NULL;
385 g->firstold1 = g->survival = g->old1 = g->reallyold = NULL;
386 g->finobjsur = g->finobjold1 = g->finobjrold = NULL;
387 g->sweepgc = NULL;
388 g->gray = g->grayagain = NULL;
389 g->weak = g->ephemeron = g->allweak = NULL;
390 g->twups = NULL;
391 g->totalbytes = sizeof(LG);
392 g->GCdebt = 0;
393 g->lastatomic = 0;
394 setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */
400 for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
402 /* memory allocation error: free partial state */
403 close_state(L);
404 L = NULL;
405 }
406 return L;
407}
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
#define WHITE0BIT
#define GCSpause
#define bitmask(b)
#define luaC_white(g)
#define cast(t, exp)
#define obj2gco(v)
#define LUA_TTHREAD
#define LUAI_GCPAUSE
#define LUAI_GCMUL
#define luai_makeseed()
#define LUA_NUMTAGS
#define setivalue(obj, x)
#define LUAI_GENMINORMUL
#define LUAI_GCSTEPSIZE
#define LUAI_GENMAJORMUL
#define setgcparam(p, v)
#define LUA_VTHREAD
static void f_luaopen(lua_State *L, void *ud)
static void preinit_thread(lua_State *L, global_State *g)
#define KGC_INC
#define incnny(L)
global_State g
lua_State l
lua_WarnFunction warnf
struct lua_State * twups
struct lua_State * mainthread
lua_CFunction panic
struct Table * mt[NUM_TAGS]

References global_State::allgc, global_State::allweak, bitmask, cast, close_state(), global_State::currentwhite, global_State::ephemeron, f_luaopen(), global_State::finobj, global_State::finobjold1, global_State::finobjrold, global_State::finobjsur, global_State::firstold1, global_State::fixedgc, global_State::frealloc, LG::g, global_State::GCdebt, global_State::gcemergency, global_State::gckind, global_State::gcpause, global_State::gcrunning, GCSpause, global_State::gcstate, global_State::gcstepmul, global_State::gcstepsize, global_State::gcstopem, global_State::genmajormul, global_State::genminormul, global_State::gray, global_State::grayagain, stringtable::hash, incnny, KGC_INC, LG::l, global_State::l_registry, global_State::lastatomic, LUA_NUMTAGS, LUA_OK, LUA_TTHREAD, LUA_VTHREAD, luaC_white, luaD_rawrunprotected(), LUAI_GCMUL, LUAI_GCPAUSE, LUAI_GCSTEPSIZE, LUAI_GENMAJORMUL, LUAI_GENMINORMUL, luai_makeseed, global_State::mainthread, global_State::mt, global_State::nilvalue, NULL, stringtable::nuse, obj2gco, global_State::old1, global_State::panic, preinit_thread(), global_State::reallyold, global_State::seed, setgcparam, setivalue, setnilvalue, stringtable::size, global_State::strt, global_State::survival, global_State::sweepgc, global_State::tobefnz, global_State::totalbytes, global_State::twups, global_State::ud, global_State::ud_warn, global_State::warnf, global_State::weak, and WHITE0BIT.

Referenced by luai_makeseed().

◆ lua_newthread()

LUA_API lua_State * lua_newthread ( lua_State * L)

Definition at line 285 of file lua-5.4.3/src/lstate.c.

285 {
286 global_State *g;
287 lua_State *L1;
288 lua_lock(L);
289 g = G(L);
290 luaC_checkGC(L);
291 /* create new thread */
292 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l;
293 L1->marked = luaC_white(g);
294 L1->tt = LUA_VTHREAD;
295 /* link it on list 'allgc' */
296 L1->next = g->allgc;
297 g->allgc = obj2gco(L1);
298 /* anchor it on L stack */
299 setthvalue2s(L, L->top, L1);
300 api_incr_top(L);
301 preinit_thread(L1, g);
302 L1->hookmask = L->hookmask;
304 L1->hook = L->hook;
305 resethookcount(L1);
306 /* initialize L1 extra space */
310 stack_init(L1, L); /* init stack */
311 lua_unlock(L);
312 return L1;
313}
#define api_incr_top(L)
#define resethookcount(L)
#define luaC_checkGC(L)
#define lua_unlock(L)
#define luai_userstatethread(L, L1)
#define luaM_newobject(L, tag, s)
#define lua_getextraspace(L)
#define LUA_EXTRASPACE
#define setthvalue2s(L, o, t)

References global_State::allgc, api_incr_top, lua_State::basehookcount, cast, G, lua_State::hook, lua_State::hookmask, LUA_EXTRASPACE, lua_getextraspace, lua_lock, LUA_TTHREAD, lua_unlock, LUA_VTHREAD, luaC_checkGC, luaC_white, luai_userstatethread, luaM_newobject, global_State::mainthread, obj2gco, preinit_thread(), resethookcount, setthvalue2s, stack_init(), and lua_State::top.

◆ lua_resetthread()

LUA_API int lua_resetthread ( lua_State * L)

Definition at line 345 of file lua-5.4.3/src/lstate.c.

345 {
346 int status;
347 lua_lock(L);
348 status = luaE_resetthread(L, L->status);
349 lua_unlock(L);
350 return status;
351}
int luaE_resetthread(lua_State *L, int status)

References lua_lock, lua_unlock, luaE_resetthread(), and lua_State::status.

Referenced by luaB_auxwrap(), and luaB_close().

◆ lua_setcstacklimit()

LUA_API int lua_setcstacklimit ( lua_State * L,
unsigned int limit )

Definition at line 99 of file lua-5.4.3/src/lstate.c.

99 {
100 UNUSED(L); UNUSED(limit);
101 return LUAI_MAXCCALLS; /* warning?? */
102}
#define LUAI_MAXCCALLS

References LUAI_MAXCCALLS, and UNUSED.

Referenced by db_setcstacklimit().

◆ luaE_checkcstack()

void luaE_checkcstack ( lua_State * L)

Definition at line 165 of file lua-5.4.3/src/lstate.c.

165 {
166 if (getCcalls(L) == LUAI_MAXCCALLS)
167 luaG_runerror(L, "C stack overflow");
168 else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11))
169 luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
170}
void luaG_runerror(lua_State *L, const char *fmt,...)
void luaD_throw(lua_State *L, int errcode)
#define LUA_ERRERR
#define getCcalls(L)

References getCcalls, LUA_ERRERR, luaD_throw(), luaG_runerror(), and LUAI_MAXCCALLS.

Referenced by ccall(), and luaE_incCstack().

◆ luaE_extendCI()

CallInfo * luaE_extendCI ( lua_State * L)

Definition at line 105 of file lua-5.4.3/src/lstate.c.

105 {
106 CallInfo *ci;
107 lua_assert(L->ci->next == NULL);
108 ci = luaM_new(L, CallInfo);
109 lua_assert(L->ci->next == NULL);
110 L->ci->next = ci;
111 ci->previous = L->ci;
112 ci->next = NULL;
113 ci->u.l.trap = 0;
114 L->nci++;
115 return ci;
116}
#define luaM_new(L, t)
volatile l_signalT trap
struct CallInfo * previous
struct CallInfo::@64::@65 l
struct CallInfo * next
union CallInfo::@64 u

References lua_State::ci, CallInfo::l, lua_assert, luaM_new, lua_State::nci, CallInfo::next, NULL, CallInfo::previous, CallInfo::trap, and CallInfo::u.

◆ luaE_freeCI()

void luaE_freeCI ( lua_State * L)

Definition at line 122 of file lua-5.4.3/src/lstate.c.

122 {
123 CallInfo *ci = L->ci;
124 CallInfo *next = ci->next;
125 ci->next = NULL;
126 while ((ci = next) != NULL) {
127 next = ci->next;
128 luaM_free(L, ci);
129 L->nci--;
130 }
131}
#define next(ls)
#define luaM_free(L, b)

References lua_State::ci, luaM_free, lua_State::nci, next, CallInfo::next, and NULL.

Referenced by freestack().

◆ luaE_freethread()

void luaE_freethread ( lua_State * L,
lua_State * L1 )

Definition at line 316 of file lua-5.4.3/src/lstate.c.

316 {
317 LX *l = fromstate(L1);
318 luaF_closeupval(L1, L1->stack); /* close all upvalues */
319 lua_assert(L1->openupval == NULL);
320 luai_userstatefree(L, L1);
321 freestack(L1);
322 luaM_free(L, l);
323}
#define luai_userstatefree(L)
void luaF_closeupval(lua_State *L, StkId level)
GCObject * openupval

References freestack(), fromstate, lua_assert, luaF_closeupval(), luai_userstatefree, luaM_free, NULL, lua_State::openupval, and lua_State::stack.

◆ luaE_incCstack()

LUAI_FUNC void luaE_incCstack ( lua_State * L)

Definition at line 173 of file lua-5.4.3/src/lstate.c.

173 {
174 L->nCcalls++;
175 if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS))
177}
void luaE_checkcstack(lua_State *L)
unsigned short nCcalls

References getCcalls, luaE_checkcstack(), LUAI_MAXCCALLS, and lua_State::nCcalls.

Referenced by resume().

◆ luaE_resetthread()

int luaE_resetthread ( lua_State * L,
int status )

Definition at line 326 of file lua-5.4.3/src/lstate.c.

326 {
327 CallInfo *ci = L->ci = &L->base_ci; /* unwind CallInfo list */
328 setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */
329 ci->func = L->stack;
330 ci->callstatus = CIST_C;
331 if (status == LUA_YIELD)
332 status = LUA_OK;
333 status = luaD_closeprotected(L, 1, status);
334 if (status != LUA_OK) /* errors? */
335 luaD_seterrorobj(L, status, L->stack + 1);
336 else
337 L->top = L->stack + 1;
338 ci->top = L->top + LUA_MINSTACK;
339 L->status = cast_byte(status);
340 luaD_reallocstack(L, cast_int(ci->top - L->stack), 0);
341 return status;
342}
void luaD_seterrorobj(lua_State *L, int errcode, StkId oldtop)
void luaD_reallocstack(lua_State *L, int newsize)
#define cast_int(i)
#define cast_byte(i)
#define LUA_YIELD
#define LUA_MINSTACK
#define s2v(o)
#define CIST_C

References lua_State::base_ci, CallInfo::callstatus, cast_byte, cast_int, lua_State::ci, CIST_C, CallInfo::func, LUA_MINSTACK, LUA_OK, LUA_YIELD, luaD_closeprotected(), luaD_reallocstack(), luaD_seterrorobj(), s2v, setnilvalue, lua_State::stack, lua_State::status, CallInfo::top, and lua_State::top.

Referenced by lua_resetthread(), and luaD_throw().

◆ luaE_setdebt()

void luaE_setdebt ( global_State * g,
l_mem debt )

Definition at line 89 of file lua-5.4.3/src/lstate.c.

89 {
90 l_mem tb = gettotalbytes(g);
91 lua_assert(tb > 0);
92 if (debt < tb - MAX_LMEM)
93 debt = tb - MAX_LMEM; /* will make 'totalbytes == MAX_LMEM' */
94 g->totalbytes = tb - debt;
95 g->GCdebt = debt;
96}
LUAI_MEM l_mem
#define MAX_LMEM

References global_State::GCdebt, gettotalbytes, lua_assert, MAX_LMEM, and global_State::totalbytes.

◆ luaE_shrinkCI()

void luaE_shrinkCI ( lua_State * L)

Definition at line 138 of file lua-5.4.3/src/lstate.c.

138 {
139 CallInfo *ci = L->ci->next; /* first free CallInfo */
140 CallInfo *next;
141 if (ci == NULL)
142 return; /* no extra elements */
143 while ((next = ci->next) != NULL) { /* two extra elements? */
144 CallInfo *next2 = next->next; /* next's next */
145 ci->next = next2; /* remove next from the list */
146 L->nci--;
147 luaM_free(L, next); /* free next */
148 if (next2 == NULL)
149 break; /* no more elements */
150 else {
151 next2->previous = ci;
152 ci = next2; /* continue */
153 }
154 }
155}

References lua_State::ci, luaM_free, lua_State::nci, next, CallInfo::next, NULL, and CallInfo::previous.

◆ luaE_warnerror()

void luaE_warnerror ( lua_State * L,
const char * where )

Definition at line 427 of file lua-5.4.3/src/lstate.c.

427 {
428 TValue *errobj = s2v(L->top - 1); /* error object */
429 const char *msg = (ttisstring(errobj))
430 ? svalue(errobj)
431 : "error object is not a string";
432 /* produce warning "error in %s (%s)" (where, msg) */
433 luaE_warning(L, "error in ", 1);
434 luaE_warning(L, where, 1);
435 luaE_warning(L, " (", 1);
436 luaE_warning(L, msg, 1);
437 luaE_warning(L, ")", 0);
438}
#define ttisstring(o)
#define svalue(o)
void luaE_warning(lua_State *L, const char *msg, int tocont)

References luaE_warning(), s2v, svalue, lua_State::top, and ttisstring.

Referenced by GCTM().

◆ luaE_warning()

void luaE_warning ( lua_State * L,
const char * msg,
int tocont )

Definition at line 417 of file lua-5.4.3/src/lstate.c.

417 {
418 lua_WarnFunction wf = G(L)->warnf;
419 if (wf != NULL)
420 wf(G(L)->ud_warn, msg, tocont);
421}
void(* lua_WarnFunction)(void *ud, const char *msg, int tocont)

References G, and NULL.

Referenced by lua_warning(), and luaE_warnerror().

◆ luai_makeseed()

static unsigned int luai_makeseed ( lua_State * L)
static

Definition at line 71 of file lua-5.4.3/src/lstate.c.

71 {
72 char buff[3 * sizeof(size_t)];
73 unsigned int h = cast_uint(time(NULL));
74 int p = 0;
75 addbuff(buff, p, L); /* heap variable */
76 addbuff(buff, p, &h); /* local variable */
77 addbuff(buff, p, &lua_newstate); /* public function */
78 lua_assert(p == sizeof(buff));
79 return luaS_hash(buff, p, h);
80}
unsigned int luaS_hash(const char *str, size_t l, unsigned int seed)
#define cast_uint(i)
LUA_API lua_State * lua_newstate(lua_Alloc f, void *ud)
#define addbuff(b, p, e)

References addbuff, cast_uint, lua_assert, lua_newstate(), luaS_hash(), and NULL.

◆ preinit_thread()

static void preinit_thread ( lua_State * L,
global_State * g )
static

Definition at line 249 of file lua-5.4.3/src/lstate.c.

249 {
250 G(L) = g;
251 L->stack = NULL;
252 L->ci = NULL;
253 L->nci = 0;
254 L->twups = L; /* thread has no upvalues */
255 L->nCcalls = 0;
256 L->errorJmp = NULL;
257 L->hook = NULL;
258 L->hookmask = 0;
259 L->basehookcount = 0;
260 L->allowhook = 1;
262 L->openupval = NULL;
263 L->status = LUA_OK;
264 L->errfunc = 0;
265 L->oldpc = 0;
266}
struct lua_longjmp * errorJmp
const Instruction * oldpc
struct lua_State * twups

References lua_State::allowhook, lua_State::basehookcount, lua_State::ci, lua_State::errfunc, lua_State::errorJmp, G, lua_State::hook, lua_State::hookmask, LUA_OK, lua_State::nCcalls, lua_State::nci, NULL, lua_State::oldpc, lua_State::openupval, resethookcount, lua_State::stack, lua_State::status, and lua_State::twups.

Referenced by lua_newstate(), and lua_newthread().

◆ stack_init()

static void stack_init ( lua_State * L1,
lua_State * L )
static

Definition at line 180 of file lua-5.4.3/src/lstate.c.

180 {
181 int i; CallInfo *ci;
182 /* initialize stack array */
184 L1->tbclist = L1->stack;
185 for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++)
186 setnilvalue(s2v(L1->stack + i)); /* erase new stack */
187 L1->top = L1->stack;
189 /* initialize first ci */
190 ci = &L1->base_ci;
191 ci->next = ci->previous = NULL;
192 ci->callstatus = CIST_C;
193 ci->func = L1->top;
194 ci->u.c.k = NULL;
195 ci->nresults = 0;
196 setnilvalue(s2v(L1->top)); /* 'function' entry for this 'ci' */
197 L1->top++;
198 ci->top = L1->top + LUA_MINSTACK;
199 L1->ci = ci;
200}
#define luaM_newvector(L, n, t)
#define BASIC_STACK_SIZE
lua_CFunction k
struct CallInfo::@64::@66 c

References lua_State::base_ci, BASIC_STACK_SIZE, CallInfo::c, CallInfo::callstatus, lua_State::ci, CIST_C, EXTRA_STACK, CallInfo::func, CallInfo::k, LUA_MINSTACK, luaM_newvector, CallInfo::next, CallInfo::nresults, NULL, CallInfo::previous, s2v, setnilvalue, lua_State::stack, lua_State::stack_last, lua_State::tbclist, CallInfo::top, lua_State::top, and CallInfo::u.

Referenced by f_luaopen(), and lua_newthread().