Lua 5.1.4: lstate.h
L0001
L0006
L0007 #ifndef lstate_h
L0008 #define lstate_h
L0009
L0010 #include "lua.h"
L0011
L0012 #include "lobject.h"
L0013 #include "ltm.h"
L0014 #include "lzio.h"
L0015
L0016
L0017
L0018 struct lua_longjmp;
L0019
L0020
L0021
L0022 #define gt(L) (&L->l_gt)
L0023
L0024
L0025 #define registry(L) (&G(L)->l_registry)
L0026
L0027
L0028
L0029 #define EXTRA_STACK 5
L0030
L0031
L0032 #define BASIC_CI_SIZE 8
L0033
L0034 #define BASIC_STACK_SIZE (2*LUA_MINSTACK)
L0035
L0036
L0037
L0038 typedef struct stringtable {
L0039 GCObject **hash;
L0040 lu_int32 nuse;
L0041 int size;
L0042 } stringtable;
L0043
L0044
L0045
L0048 typedef struct CallInfo {
L0049 StkId base;
L0050 StkId func;
L0051 StkId top;
L0052 const Instruction *savedpc;
L0053 int nresults;
L0054 int tailcalls;
L0055 } CallInfo;
L0056
L0057
L0058
L0059 #define curr_func(L) (clvalue(L->ci->func))
L0060 #define ci_func(ci) (clvalue((ci)->func))
L0061 #define f_isLua(ci) (!ci_func(ci)->c.isC)
L0062 #define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci))
L0063
L0064
L0065
L0068 typedef struct global_State {
L0069 stringtable strt;
L0070 lua_Alloc frealloc;
L0071 void *ud;
L0072 lu_byte currentwhite;
L0073 lu_byte gcstate;
L0074 int sweepstrgc;
L0075 GCObject *rootgc;
L0076 GCObject **sweepgc;
L0077 GCObject *gray;
L0078 GCObject *grayagain;
L0079 GCObject *weak;
L0080 GCObject *tmudata;
L0081 Mbuffer buff;
L0082 lu_mem GCthreshold;
L0083 lu_mem totalbytes;
L0084 lu_mem estimate;
L0085 lu_mem gcdept;
L0086 int gcpause;
L0087 int gcstepmul;
L0088 lua_CFunction panic;
L0089 TValue l_registry;
L0090 struct lua_State *mainthread;
L0091 UpVal uvhead;
L0092 struct Table *mt[NUM_TAGS];
L0093 TString *tmname[TM_N];
L0094 } global_State;
L0095
L0096
L0097
L0100 struct lua_State {
L0101 CommonHeader;
L0102 lu_byte status;
L0103 StkId top;
L0104 StkId base;
L0105 global_State *l_G;
L0106 CallInfo *ci;
L0107 const Instruction *savedpc;
L0108 StkId stack_last;
L0109 StkId stack;
L0110 CallInfo *end_ci;
L0111 CallInfo *base_ci;
L0112 int stacksize;
L0113 int size_ci;
L0114 unsigned short nCcalls;
L0115 unsigned short baseCcalls;
L0116 lu_byte hookmask;
L0117 lu_byte allowhook;
L0118 int basehookcount;
L0119 int hookcount;
L0120 lua_Hook hook;
L0121 TValue l_gt;
L0122 TValue env;
L0123 GCObject *openupval;
L0124 GCObject *gclist;
L0125 struct lua_longjmp *errorJmp;
L0126 ptrdiff_t errfunc;
L0127 };
L0128
L0129
L0130 #define G(L) (L->l_G)
L0131
L0132
L0133
L0136 union GCObject {
L0137 GCheader gch;
L0138 union TString ts;
L0139 union Udata u;
L0140 union Closure cl;
L0141 struct Table h;
L0142 struct Proto p;
L0143 struct UpVal uv;
L0144 struct lua_State th;
L0145 };
L0146
L0147
L0148
L0149 #define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
L0150 #define gco2ts(o) (&rawgco2ts(o)->tsv)
L0151 #define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
L0152 #define gco2u(o) (&rawgco2u(o)->uv)
L0153 #define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
L0154 #define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
L0155 #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
L0156 #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
L0157 #define ngcotouv(o) \
L0158 check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
L0159 #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
L0160
L0161
L0162 #define obj2gco(v) (cast(GCObject *, (v)))
L0163
L0164
L0165 LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
L0166 LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
L0167
L0168 #endif
L0169
Generated by pretty.lua