Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lstate.h File Reference
#include "lua.h"
#include "lobject.h"
#include "ltm.h"
#include "lzio.h"
#include <signal.h>

Go to the source code of this file.

Data Structures

struct  stringtable
 
struct  CallInfo
 
struct  global_State
 
struct  lua_State
 
union  GCUnion
 

Macros

#define yieldable(L)   (((L)->nCcalls & 0xffff0000) == 0)
 
#define getCcalls(L)   ((L)->nCcalls & 0xffff)
 
#define incnny(L)   ((L)->nCcalls += 0x10000)
 
#define decnny(L)   ((L)->nCcalls -= 0x10000)
 
#define nyci   (0x10000 | 1)
 
#define l_signalT   sig_atomic_t
 
#define EXTRA_STACK   5
 
#define BASIC_STACK_SIZE   (2*LUA_MINSTACK)
 
#define stacksize(th)   cast_int((th)->stack_last - (th)->stack)
 
#define KGC_INC   0 /* incremental gc */
 
#define KGC_GEN   1 /* generational gc */
 
#define CIST_OAH   (1<<0) /* original value of 'allowhook' */
 
#define CIST_C   (1<<1) /* call is running a C function */
 
#define CIST_FRESH   (1<<2) /* call is on a fresh "luaV_execute" frame */
 
#define CIST_HOOKED   (1<<3) /* call is running a debug hook */
 
#define CIST_YPCALL   (1<<4) /* doing a yieldable protected call */
 
#define CIST_TAIL   (1<<5) /* call was tail called */
 
#define CIST_HOOKYIELD   (1<<6) /* last hook called yielded */
 
#define CIST_FIN   (1<<7) /* call is running a finalizer */
 
#define CIST_TRAN   (1<<8) /* 'ci' has transfer information */
 
#define CIST_CLSRET   (1<<9) /* function is closing tbc variables */
 
#define CIST_RECST   10
 
#define getcistrecst(ci)   (((ci)->callstatus >> CIST_RECST) & 7)
 
#define setcistrecst(ci, st)
 
#define isLua(ci)   (!((ci)->callstatus & CIST_C))
 
#define isLuacode(ci)   (!((ci)->callstatus & (CIST_C | CIST_HOOKED)))
 
#define setoah(st, v)   ((st) = ((st) & ~CIST_OAH) | (v))
 
#define getoah(st)   ((st) & CIST_OAH)
 
#define G(L)   (L->l_G)
 
#define completestate(g)   ttisnil(&g->nilvalue)
 
#define cast_u(o)   cast(union GCUnion *, (o))
 
#define gco2ts(o)    check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))
 
#define gco2u(o)   check_exp((o)->tt == LUA_VUSERDATA, &((cast_u(o))->u))
 
#define gco2lcl(o)   check_exp((o)->tt == LUA_VLCL, &((cast_u(o))->cl.l))
 
#define gco2ccl(o)   check_exp((o)->tt == LUA_VCCL, &((cast_u(o))->cl.c))
 
#define gco2cl(o)    check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))
 
#define gco2t(o)   check_exp((o)->tt == LUA_VTABLE, &((cast_u(o))->h))
 
#define gco2p(o)   check_exp((o)->tt == LUA_VPROTO, &((cast_u(o))->p))
 
#define gco2th(o)   check_exp((o)->tt == LUA_VTHREAD, &((cast_u(o))->th))
 
#define gco2upv(o)   check_exp((o)->tt == LUA_VUPVAL, &((cast_u(o))->upv))
 
#define obj2gco(v)   check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc))
 
#define gettotalbytes(g)   cast(lu_mem, (g)->totalbytes + (g)->GCdebt)
 

Typedefs

typedef struct stringtable stringtable
 
typedef struct CallInfo CallInfo
 
typedef struct global_State global_State
 

Functions

LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt)
 
LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1)
 
LUAI_FUNC CallInfoluaE_extendCI (lua_State *L)
 
LUAI_FUNC void luaE_freeCI (lua_State *L)
 
LUAI_FUNC void luaE_shrinkCI (lua_State *L)
 
LUAI_FUNC void luaE_checkcstack (lua_State *L)
 
LUAI_FUNC void luaE_incCstack (lua_State *L)
 
LUAI_FUNC void luaE_warning (lua_State *L, const char *msg, int tocont)
 
LUAI_FUNC void luaE_warnerror (lua_State *L, const char *where)
 
LUAI_FUNC int luaE_resetthread (lua_State *L, int status)
 

Macro Definition Documentation

◆ BASIC_STACK_SIZE

#define BASIC_STACK_SIZE   (2*LUA_MINSTACK)

Definition at line 140 of file lua-5.4.3/src/lstate.h.

◆ cast_u

#define cast_u ( o)    cast(union GCUnion *, (o))

Definition at line 365 of file lua-5.4.3/src/lstate.h.

◆ CIST_C

#define CIST_C   (1<<1) /* call is running a C function */

Definition at line 206 of file lua-5.4.3/src/lstate.h.

Referenced by luaD_precall(), luaE_resetthread(), and stack_init().

◆ CIST_CLSRET

#define CIST_CLSRET   (1<<9) /* function is closing tbc variables */

Definition at line 214 of file lua-5.4.3/src/lstate.h.

Referenced by finishCcall(), luaD_poscall(), and moveresults().

◆ CIST_FIN

#define CIST_FIN   (1<<7) /* call is running a finalizer */

Definition at line 212 of file lua-5.4.3/src/lstate.h.

◆ CIST_FRESH

#define CIST_FRESH   (1<<2) /* call is on a fresh "luaV_execute" frame */

Definition at line 207 of file lua-5.4.3/src/lstate.h.

◆ CIST_HOOKED

#define CIST_HOOKED   (1<<3) /* call is running a debug hook */

Definition at line 208 of file lua-5.4.3/src/lstate.h.

◆ CIST_HOOKYIELD

#define CIST_HOOKYIELD   (1<<6) /* last hook called yielded */

Definition at line 211 of file lua-5.4.3/src/lstate.h.

◆ CIST_OAH

#define CIST_OAH   (1<<0) /* original value of 'allowhook' */

Definition at line 205 of file lua-5.4.3/src/lstate.h.

◆ CIST_RECST

#define CIST_RECST   10

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

◆ CIST_TAIL

#define CIST_TAIL   (1<<5) /* call was tail called */

Definition at line 210 of file lua-5.4.3/src/lstate.h.

◆ CIST_TRAN

#define CIST_TRAN   (1<<8) /* 'ci' has transfer information */

Definition at line 213 of file lua-5.4.3/src/lstate.h.

Referenced by auxgetinfo(), luaD_hook(), and luaD_poscall().

◆ CIST_YPCALL

#define CIST_YPCALL   (1<<4) /* doing a yieldable protected call */

Definition at line 209 of file lua-5.4.3/src/lstate.h.

◆ completestate

#define completestate ( g)    ttisnil(&g->nilvalue)

Definition at line 336 of file lua-5.4.3/src/lstate.h.

Referenced by close_state(), and tryagain().

◆ decnny

#define decnny ( L)    ((L)->nCcalls -= 0x10000)

Definition at line 109 of file lua-5.4.3/src/lstate.h.

Referenced by luaD_protectedparser().

◆ EXTRA_STACK

#define EXTRA_STACK   5

Definition at line 137 of file lua-5.4.3/src/lstate.h.

◆ G

#define G ( L)    (L->l_G)

Definition at line 330 of file lua-5.4.3/src/lstate.h.

◆ gco2ccl

#define gco2ccl ( o)    check_exp((o)->tt == LUA_VCCL, &((cast_u(o))->cl.c))

Definition at line 372 of file lua-5.4.3/src/lstate.h.

◆ gco2cl

#define gco2cl ( o)     check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))

Definition at line 373 of file lua-5.4.3/src/lstate.h.

373#define gco2cl(o) \
374 check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))

◆ gco2lcl

#define gco2lcl ( o)    check_exp((o)->tt == LUA_VLCL, &((cast_u(o))->cl.l))

Definition at line 371 of file lua-5.4.3/src/lstate.h.

◆ gco2p

#define gco2p ( o)    check_exp((o)->tt == LUA_VPROTO, &((cast_u(o))->p))

Definition at line 376 of file lua-5.4.3/src/lstate.h.

◆ gco2t

#define gco2t ( o)    check_exp((o)->tt == LUA_VTABLE, &((cast_u(o))->h))

Definition at line 375 of file lua-5.4.3/src/lstate.h.

◆ gco2th

#define gco2th ( o)    check_exp((o)->tt == LUA_VTHREAD, &((cast_u(o))->th))

Definition at line 377 of file lua-5.4.3/src/lstate.h.

◆ gco2ts

#define gco2ts ( o)     check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))

Definition at line 368 of file lua-5.4.3/src/lstate.h.

368#define gco2ts(o) \
369 check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))

◆ gco2u

#define gco2u ( o)    check_exp((o)->tt == LUA_VUSERDATA, &((cast_u(o))->u))

Definition at line 370 of file lua-5.4.3/src/lstate.h.

◆ gco2upv

#define gco2upv ( o)    check_exp((o)->tt == LUA_VUPVAL, &((cast_u(o))->upv))

◆ getCcalls

#define getCcalls ( L)    ((L)->nCcalls & 0xffff)

Definition at line 102 of file lua-5.4.3/src/lstate.h.

Referenced by ccall(), lua_resume(), luaE_checkcstack(), and luaE_incCstack().

◆ getcistrecst

#define getcistrecst ( ci)    (((ci)->callstatus >> CIST_RECST) & 7)

Definition at line 228 of file lua-5.4.3/src/lstate.h.

Referenced by finishpcallk().

◆ getoah

#define getoah ( st)    ((st) & CIST_OAH)

Definition at line 243 of file lua-5.4.3/src/lstate.h.

◆ gettotalbytes

#define gettotalbytes ( g)    cast(lu_mem, (g)->totalbytes + (g)->GCdebt)

Definition at line 389 of file lua-5.4.3/src/lstate.h.

◆ incnny

#define incnny ( L)    ((L)->nCcalls += 0x10000)

Definition at line 106 of file lua-5.4.3/src/lstate.h.

Referenced by lua_newstate(), and luaD_protectedparser().

◆ isLua

#define isLua ( ci)    (!((ci)->callstatus & CIST_C))

Definition at line 236 of file lua-5.4.3/src/lstate.h.

◆ isLuacode

#define isLuacode ( ci)    (!((ci)->callstatus & (CIST_C | CIST_HOOKED)))

Definition at line 239 of file lua-5.4.3/src/lstate.h.

Referenced by lua_yieldk(), luaT_callTM(), and luaT_callTMres().

◆ KGC_GEN

#define KGC_GEN   1 /* generational gc */

Definition at line 147 of file lua-5.4.3/src/lstate.h.

◆ KGC_INC

#define KGC_INC   0 /* incremental gc */

◆ l_signalT

#define l_signalT   sig_atomic_t

Definition at line 126 of file lua-5.4.3/src/lstate.h.

◆ nyci

#define nyci   (0x10000 | 1)

Definition at line 112 of file lua-5.4.3/src/lstate.h.

Referenced by luaD_callnoyield().

◆ obj2gco

#define obj2gco ( v)    check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc))

Definition at line 385 of file lua-5.4.3/src/lstate.h.

◆ setcistrecst

#define setcistrecst ( ci,
st )
Value:
check_exp(((st) & 7) == (st), /* status must fit in three bits */ \
((ci)->callstatus = ((ci)->callstatus & ~(7 << CIST_RECST)) \
| ((st) << CIST_RECST)))
#define check_exp(c, e)
#define CIST_RECST

Definition at line 229 of file lua-5.4.3/src/lstate.h.

229#define setcistrecst(ci,st) \
230 check_exp(((st) & 7) == (st), /* status must fit in three bits */ \
231 ((ci)->callstatus = ((ci)->callstatus & ~(7 << CIST_RECST)) \
232 | ((st) << CIST_RECST)))

Referenced by finishpcallk(), and precover().

◆ setoah

#define setoah ( st,
v )   ((st) = ((st) & ~CIST_OAH) | (v))

Definition at line 242 of file lua-5.4.3/src/lstate.h.

◆ stacksize

#define stacksize ( th)    cast_int((th)->stack_last - (th)->stack)

◆ yieldable

#define yieldable ( L)    (((L)->nCcalls & 0xffff0000) == 0)

Typedef Documentation

◆ CallInfo

typedef struct CallInfo CallInfo

◆ global_State

typedef struct global_State global_State

◆ stringtable

typedef struct stringtable stringtable

Function Documentation

◆ luaE_checkcstack()

LUAI_FUNC 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 LUAI_MAXCCALLS
#define getCcalls(L)

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

Referenced by ccall(), and luaE_incCstack().

◆ luaE_extendCI()

LUAI_FUNC CallInfo * luaE_extendCI ( lua_State * L)

Definition at line 112 of file lua-5.2.4/src/lstate.c.

112 {
113 CallInfo *ci = luaM_new(L, CallInfo);
114 lua_assert(L->ci->next == NULL);
115 L->ci->next = ci;
116 ci->previous = L->ci;
117 ci->next = NULL;
118 return ci;
119}
#define NULL
Definition gmacros.h:924
#define lua_assert(c)
#define luaM_new(L, t)
struct CallInfo * previous
struct CallInfo * next

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()

LUAI_FUNC void luaE_freeCI ( lua_State * L)

Definition at line 122 of file lua-5.2.4/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 }
130}
#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(), freestack(), freestack(), luaD_shrinkstack(), and sweepthread().

◆ luaE_freethread()

LUAI_FUNC void luaE_freethread ( lua_State * L,
lua_State * L1 )

Definition at line 134 of file lua-5.1.5/src/lstate.c.

134 {
135 luaF_close(L1, L1->stack); /* close all upvalues for this thread */
136 lua_assert(L1->openupval == NULL);
138 freestack(L, L1);
140}
void luaF_close(lua_State *L, StkId level)
#define luaM_freemem(L, b, s)
#define state_size(x)
static void freestack(lua_State *L, lua_State *L1)
#define fromstate(l)
#define luai_userstatefree(L)
GCObject * openupval

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

Referenced by freeobj(), freeobj(), freeobj(), and freeobj().

◆ 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()

LUAI_FUNC 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 setnilvalue(obj)
#define LUA_YIELD
#define LUA_MINSTACK
#define LUA_OK
int luaD_closeprotected(lua_State *L, ptrdiff_t level, int status)
#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()

LUAI_FUNC void luaE_setdebt ( global_State * g,
l_mem debt )

◆ luaE_shrinkCI()

LUAI_FUNC void luaE_shrinkCI ( lua_State * L)

Definition at line 137 of file lua-5.3.6/src/lstate.c.

137 {
138 CallInfo *ci = L->ci;
139 CallInfo *next2; /* next's next */
140 /* while there are two nexts */
141 while (ci->next != NULL && (next2 = ci->next->next) != NULL) {
142 luaM_free(L, ci->next); /* free next */
143 L->nci--;
144 ci->next = next2; /* remove 'next' from the list */
145 next2->previous = ci;
146 ci = next2; /* keep next's next */
147 }
148}
unsigned short nci

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

Referenced by luaD_shrinkstack().

◆ luaE_warnerror()

LUAI_FUNC 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()

LUAI_FUNC 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}
#define G(L)
void(* lua_WarnFunction)(void *ud, const char *msg, int tocont)

References G, and NULL.

Referenced by lua_warning(), and luaE_warnerror().