aboutsummaryrefslogtreecommitdiff
path: root/src/lua/lstate.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/lstate.h')
-rw-r--r--src/lua/lstate.h46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/lua/lstate.h b/src/lua/lstate.h
index 38a6c9b..c1283bb 100644
--- a/src/lua/lstate.h
+++ b/src/lua/lstate.h
@@ -156,6 +156,18 @@ typedef struct stringtable {
156 156
157/* 157/*
158** Information about a call. 158** Information about a call.
159** About union 'u':
160** - field 'l' is used only for Lua functions;
161** - field 'c' is used only for C functions.
162** About union 'u2':
163** - field 'funcidx' is used only by C functions while doing a
164** protected call;
165** - field 'nyield' is used only while a function is "doing" an
166** yield (from the yield until the next resume);
167** - field 'nres' is used only while closing tbc variables when
168** returning from a C function;
169** - field 'transferinfo' is used only during call/returnhooks,
170** before the function starts or after it ends.
159*/ 171*/
160typedef struct CallInfo { 172typedef struct CallInfo {
161 StkId func; /* function index in the stack */ 173 StkId func; /* function index in the stack */
@@ -176,6 +188,7 @@ typedef struct CallInfo {
176 union { 188 union {
177 int funcidx; /* called-function index */ 189 int funcidx; /* called-function index */
178 int nyield; /* number of values yielded */ 190 int nyield; /* number of values yielded */
191 int nres; /* number of values returned */
179 struct { /* info about transferred values (for call/return hooks) */ 192 struct { /* info about transferred values (for call/return hooks) */
180 unsigned short ftransfer; /* offset of first value transferred */ 193 unsigned short ftransfer; /* offset of first value transferred */
181 unsigned short ntransfer; /* number of values transferred */ 194 unsigned short ntransfer; /* number of values transferred */
@@ -191,17 +204,34 @@ typedef struct CallInfo {
191*/ 204*/
192#define CIST_OAH (1<<0) /* original value of 'allowhook' */ 205#define CIST_OAH (1<<0) /* original value of 'allowhook' */
193#define CIST_C (1<<1) /* call is running a C function */ 206#define CIST_C (1<<1) /* call is running a C function */
194#define CIST_FRESH (1<<2) /* call is on a fresh "luaV_execute" frame */ 207#define CIST_FRESH (1<<2) /* call is on a fresh "luaV_execute" frame */
195#define CIST_HOOKED (1<<3) /* call is running a debug hook */ 208#define CIST_HOOKED (1<<3) /* call is running a debug hook */
196#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ 209#define CIST_YPCALL (1<<4) /* doing a yieldable protected call */
197#define CIST_TAIL (1<<5) /* call was tail called */ 210#define CIST_TAIL (1<<5) /* call was tail called */
198#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ 211#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */
199#define CIST_FIN (1<<7) /* call is running a finalizer */ 212#define CIST_FIN (1<<7) /* call is running a finalizer */
200#define CIST_TRAN (1<<8) /* 'ci' has transfer information */ 213#define CIST_TRAN (1<<8) /* 'ci' has transfer information */
214#define CIST_CLSRET (1<<9) /* function is closing tbc variables */
215/* Bits 10-12 are used for CIST_RECST (see below) */
216#define CIST_RECST 10
201#if defined(LUA_COMPAT_LT_LE) 217#if defined(LUA_COMPAT_LT_LE)
202#define CIST_LEQ (1<<9) /* using __lt for __le */ 218#define CIST_LEQ (1<<13) /* using __lt for __le */
203#endif 219#endif
204 220
221
222/*
223** Field CIST_RECST stores the "recover status", used to keep the error
224** status while closing to-be-closed variables in coroutines, so that
225** Lua can correctly resume after an yield from a __close method called
226** because of an error. (Three bits are enough for error status.)
227*/
228#define getcistrecst(ci) (((ci)->callstatus >> CIST_RECST) & 7)
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)))
233
234
205/* active function is a Lua function */ 235/* active function is a Lua function */
206#define isLua(ci) (!((ci)->callstatus & CIST_C)) 236#define isLua(ci) (!((ci)->callstatus & CIST_C))
207 237
@@ -230,6 +260,7 @@ typedef struct global_State {
230 lu_byte currentwhite; 260 lu_byte currentwhite;
231 lu_byte gcstate; /* state of garbage collector */ 261 lu_byte gcstate; /* state of garbage collector */
232 lu_byte gckind; /* kind of GC running */ 262 lu_byte gckind; /* kind of GC running */
263 lu_byte gcstopem; /* stops emergency collections */
233 lu_byte genminormul; /* control for minor generational collections */ 264 lu_byte genminormul; /* control for minor generational collections */
234 lu_byte genmajormul; /* control for major generational collections */ 265 lu_byte genmajormul; /* control for major generational collections */
235 lu_byte gcrunning; /* true if GC is running */ 266 lu_byte gcrunning; /* true if GC is running */
@@ -281,6 +312,7 @@ struct lua_State {
281 StkId stack_last; /* end of stack (last element + 1) */ 312 StkId stack_last; /* end of stack (last element + 1) */
282 StkId stack; /* stack base */ 313 StkId stack; /* stack base */
283 UpVal *openupval; /* list of open upvalues in this stack */ 314 UpVal *openupval; /* list of open upvalues in this stack */
315 StkId tbclist; /* list of to-be-closed variables */
284 GCObject *gclist; 316 GCObject *gclist;
285 struct lua_State *twups; /* list of threads with open upvalues */ 317 struct lua_State *twups; /* list of threads with open upvalues */
286 struct lua_longjmp *errorJmp; /* current error recover point */ 318 struct lua_longjmp *errorJmp; /* current error recover point */
@@ -297,6 +329,12 @@ struct lua_State {
297 329
298#define G(L) (L->l_G) 330#define G(L) (L->l_G)
299 331
332/*
333** 'g->nilvalue' being a nil value flags that the state was completely
334** build.
335*/
336#define completestate(g) ttisnil(&g->nilvalue)
337
300 338
301/* 339/*
302** Union of all collectable objects (only for conversions) 340** Union of all collectable objects (only for conversions)