The Battle for Wesnoth  1.15.11+dev
Classes | Macros | Typedefs | Functions
lstate.h File Reference
#include "lua.h"
#include "lobject.h"
#include "ltm.h"
#include "lzio.h"
#include <signal.h>
Include dependency graph for lstate.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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) /* call is 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 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 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)
 

Macro Definition Documentation

◆ BASIC_STACK_SIZE

#define BASIC_STACK_SIZE   (2*LUA_MINSTACK)

Definition at line 140 of file lstate.h.

Referenced by stack_init().

◆ cast_u

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

Definition at line 327 of file lstate.h.

◆ CIST_C

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

Definition at line 193 of file lstate.h.

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

◆ CIST_FIN

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

Definition at line 199 of file lstate.h.

Referenced by GCTM(), and getfuncname().

◆ CIST_FRESH

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

Definition at line 194 of file lstate.h.

Referenced by ccall(), and luaV_execute().

◆ CIST_HOOKED

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

Definition at line 195 of file lstate.h.

Referenced by funcnamefromcode(), lua_yieldk(), and luaD_hook().

◆ CIST_HOOKYIELD

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

Definition at line 198 of file lstate.h.

Referenced by luaG_traceexec().

◆ CIST_OAH

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

Definition at line 192 of file lstate.h.

◆ CIST_TAIL

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

Definition at line 197 of file lstate.h.

Referenced by auxgetinfo(), getfuncname(), luaD_hookcall(), and luaD_pretailcall().

◆ CIST_TRAN

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

Definition at line 200 of file lstate.h.

Referenced by auxgetinfo(), and luaD_hook().

◆ CIST_YPCALL

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

Definition at line 196 of file lstate.h.

Referenced by findpcall(), finishCcall(), and lua_pcallk().

◆ decnny

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

Definition at line 109 of file lstate.h.

Referenced by luaD_protectedparser().

◆ EXTRA_STACK

#define EXTRA_STACK   5

Definition at line 137 of file lstate.h.

Referenced by freestack(), lua_checkstack(), luaD_reallocstack(), stack_init(), and traversethread().

◆ G

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

◆ gco2ccl

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

Definition at line 334 of file lstate.h.

Referenced by freeobj(), getgclist(), luaF_newCclosure(), and propagatemark().

◆ gco2cl

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

Definition at line 335 of file lstate.h.

◆ gco2lcl

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

Definition at line 333 of file lstate.h.

Referenced by freeobj(), getgclist(), luaF_newLclosure(), and propagatemark().

◆ gco2p

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

Definition at line 338 of file lstate.h.

Referenced by freeobj(), getgclist(), luaF_newproto(), and propagatemark().

◆ gco2t

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

◆ gco2th

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

Definition at line 339 of file lstate.h.

Referenced by freeobj(), getgclist(), propagatemark(), and sweep2old().

◆ gco2ts

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

Definition at line 330 of file lstate.h.

Referenced by createstrobj(), and freeobj().

◆ gco2u

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

Definition at line 332 of file lstate.h.

Referenced by freeobj(), getgclist(), luaS_newudata(), propagatemark(), and reallymarkobject().

◆ gco2upv

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

Definition at line 340 of file lstate.h.

Referenced by freeobj(), luaF_initupvals(), newupval(), reallymarkobject(), and sweep2old().

◆ getCcalls

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

Definition at line 102 of file lstate.h.

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

◆ getoah

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

Definition at line 213 of file lstate.h.

Referenced by recover().

◆ gettotalbytes

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

◆ incnny

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

Definition at line 106 of file lstate.h.

Referenced by lua_newstate(), and luaD_protectedparser().

◆ isLua

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

◆ isLuacode

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

Definition at line 209 of file lstate.h.

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

◆ KGC_GEN

#define KGC_GEN   1 /* generational gc */

Definition at line 147 of file lstate.h.

Referenced by atomic2gen(), lua_gc(), luaC_barrierback_(), luaC_changemode(), and stepgenfull().

◆ KGC_INC

#define KGC_INC   0 /* incremental gc */

◆ l_signalT

#define l_signalT   sig_atomic_t

Definition at line 126 of file lstate.h.

◆ nyci

#define nyci   (0x10000 | 1)

Definition at line 112 of file lstate.h.

Referenced by luaD_callnoyield().

◆ obj2gco

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

◆ setoah

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

Definition at line 212 of file lstate.h.

Referenced by lua_pcallk().

◆ stacksize

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

◆ yieldable

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

Definition at line 99 of file lstate.h.

Referenced by finishCcall(), lua_callk(), lua_isyieldable(), lua_pcallk(), and lua_yieldk().

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 lstate.cpp.

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)

◆ luaE_freeCI()

LUAI_FUNC void luaE_freeCI ( lua_State L)

Definition at line 122 of file lstate.cpp.

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

Referenced by freestack().

◆ luaE_freethread()

LUAI_FUNC void luaE_freethread ( lua_State L,
lua_State L1 
)

◆ luaE_incCstack()

LUAI_FUNC void luaE_incCstack ( lua_State L)

Definition at line 173 of file lstate.cpp.

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

Referenced by resume().

◆ 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 138 of file lstate.cpp.

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

Referenced by luaD_shrinkstack().

◆ luaE_warnerror()

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

Definition at line 422 of file lstate.cpp.

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

Referenced by callclosemth(), and GCTM().

◆ luaE_warning()

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

Definition at line 412 of file lstate.cpp.

References G.

Referenced by lua_warning(), and luaE_warnerror().