annotate lib/lua/lua-5.2.2/lstate.h @ 2412:e7a551f458e1

LoadSound - cause of the crash exe file
author Ritor1
date Wed, 16 Jul 2014 17:22:12 +0600
parents 41cc4dd3c122
children
rev   line source
1866
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
1 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
2 ** $Id: lstate.h,v 2.82 2012/07/02 13:37:04 roberto Exp $
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
3 ** Global State
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
4 ** See Copyright Notice in lua.h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
5 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
6
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
7 #ifndef lstate_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
8 #define lstate_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
9
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
10 #include "lua.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
11
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
12 #include "lobject.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
13 #include "ltm.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
14 #include "lzio.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
15
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
16
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
17 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
18
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
19 ** Some notes about garbage-collected objects: All objects in Lua must
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
20 ** be kept somehow accessible until being freed.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
21 **
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
22 ** Lua keeps most objects linked in list g->allgc. The link uses field
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
23 ** 'next' of the CommonHeader.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
24 **
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
25 ** Strings are kept in several lists headed by the array g->strt.hash.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
26 **
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
27 ** Open upvalues are not subject to independent garbage collection. They
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
28 ** are collected together with their respective threads. Lua keeps a
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
29 ** double-linked list with all open upvalues (g->uvhead) so that it can
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
30 ** mark objects referred by them. (They are always gray, so they must
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
31 ** be remarked in the atomic step. Usually their contents would be marked
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
32 ** when traversing the respective threads, but the thread may already be
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
33 ** dead, while the upvalue is still accessible through closures.)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
34 **
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
35 ** Objects with finalizers are kept in the list g->finobj.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
36 **
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
37 ** The list g->tobefnz links all objects being finalized.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
38
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
39 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
40
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
41
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
42 struct lua_longjmp; /* defined in ldo.c */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
43
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
44
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
45
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
46 /* extra stack space to handle TM calls and some other extras */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
47 #define EXTRA_STACK 5
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
48
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
49
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
50 #define BASIC_STACK_SIZE (2*LUA_MINSTACK)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
51
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
52
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
53 /* kinds of Garbage Collection */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
54 #define KGC_NORMAL 0
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
55 #define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
56 #define KGC_GEN 2 /* generational collection */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
57
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
58
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
59 typedef struct stringtable {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
60 GCObject **hash;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
61 lu_int32 nuse; /* number of elements */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
62 int size;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
63 } stringtable;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
64
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
65
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
66 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
67 ** information about a call
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
68 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
69 typedef struct CallInfo {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
70 StkId func; /* function index in the stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
71 StkId top; /* top for this function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
72 struct CallInfo *previous, *next; /* dynamic call link */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
73 short nresults; /* expected number of results from this function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
74 lu_byte callstatus;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
75 ptrdiff_t extra;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
76 union {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
77 struct { /* only for Lua functions */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
78 StkId base; /* base for this function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
79 const Instruction *savedpc;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
80 } l;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
81 struct { /* only for C functions */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
82 int ctx; /* context info. in case of yields */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
83 lua_CFunction k; /* continuation in case of yields */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
84 ptrdiff_t old_errfunc;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
85 lu_byte old_allowhook;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
86 lu_byte status;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
87 } c;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
88 } u;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
89 } CallInfo;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
90
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
91
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
92 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
93 ** Bits in CallInfo status
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
94 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
95 #define CIST_LUA (1<<0) /* call is running a Lua function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
96 #define CIST_HOOKED (1<<1) /* call is running a debug hook */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
97 #define CIST_REENTRY (1<<2) /* call is running on same invocation of
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
98 luaV_execute of previous call */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
99 #define CIST_YIELDED (1<<3) /* call reentered after suspension */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
100 #define CIST_YPCALL (1<<4) /* call is a yieldable protected call */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
101 #define CIST_STAT (1<<5) /* call has an error status (pcall) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
102 #define CIST_TAIL (1<<6) /* call was tail called */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
103 #define CIST_HOOKYIELD (1<<7) /* last hook called yielded */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
104
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
105
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
106 #define isLua(ci) ((ci)->callstatus & CIST_LUA)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
107
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
108
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
109 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
110 ** `global state', shared by all threads of this state
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
111 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
112 typedef struct global_State {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
113 lua_Alloc frealloc; /* function to reallocate memory */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
114 void *ud; /* auxiliary data to `frealloc' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
115 lu_mem totalbytes; /* number of bytes currently allocated - GCdebt */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
116 l_mem GCdebt; /* bytes allocated not yet compensated by the collector */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
117 lu_mem GCmemtrav; /* memory traversed by the GC */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
118 lu_mem GCestimate; /* an estimate of the non-garbage memory in use */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
119 stringtable strt; /* hash table for strings */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
120 TValue l_registry;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
121 unsigned int seed; /* randomized seed for hashes */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
122 lu_byte currentwhite;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
123 lu_byte gcstate; /* state of garbage collector */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
124 lu_byte gckind; /* kind of GC running */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
125 lu_byte gcrunning; /* true if GC is running */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
126 int sweepstrgc; /* position of sweep in `strt' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
127 GCObject *allgc; /* list of all collectable objects */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
128 GCObject *finobj; /* list of collectable objects with finalizers */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
129 GCObject **sweepgc; /* current position of sweep in list 'allgc' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
130 GCObject **sweepfin; /* current position of sweep in list 'finobj' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
131 GCObject *gray; /* list of gray objects */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
132 GCObject *grayagain; /* list of objects to be traversed atomically */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
133 GCObject *weak; /* list of tables with weak values */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
134 GCObject *ephemeron; /* list of ephemeron tables (weak keys) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
135 GCObject *allweak; /* list of all-weak tables */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
136 GCObject *tobefnz; /* list of userdata to be GC */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
137 UpVal uvhead; /* head of double-linked list of all open upvalues */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
138 Mbuffer buff; /* temporary buffer for string concatenation */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
139 int gcpause; /* size of pause between successive GCs */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
140 int gcmajorinc; /* pause between major collections (only in gen. mode) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
141 int gcstepmul; /* GC `granularity' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
142 lua_CFunction panic; /* to be called in unprotected errors */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
143 struct lua_State *mainthread;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
144 const lua_Number *version; /* pointer to version number */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
145 TString *memerrmsg; /* memory-error message */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
146 TString *tmname[TM_N]; /* array with tag-method names */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
147 struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
148 } global_State;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
149
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
150
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
151 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
152 ** `per thread' state
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
153 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
154 struct lua_State {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
155 CommonHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
156 lu_byte status;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
157 StkId top; /* first free slot in the stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
158 global_State *l_G;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
159 CallInfo *ci; /* call info for current function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
160 const Instruction *oldpc; /* last pc traced */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
161 StkId stack_last; /* last free slot in the stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
162 StkId stack; /* stack base */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
163 int stacksize;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
164 unsigned short nny; /* number of non-yieldable calls in stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
165 unsigned short nCcalls; /* number of nested C calls */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
166 lu_byte hookmask;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
167 lu_byte allowhook;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
168 int basehookcount;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
169 int hookcount;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
170 lua_Hook hook;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
171 GCObject *openupval; /* list of open upvalues in this stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
172 GCObject *gclist;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
173 struct lua_longjmp *errorJmp; /* current error recover point */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
174 ptrdiff_t errfunc; /* current error handling function (stack index) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
175 CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
176 };
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
177
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
178
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
179 #define G(L) (L->l_G)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
180
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
181
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
182 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
183 ** Union of all collectable objects
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
184 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
185 union GCObject {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
186 GCheader gch; /* common header */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
187 union TString ts;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
188 union Udata u;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
189 union Closure cl;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
190 struct Table h;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
191 struct Proto p;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
192 struct UpVal uv;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
193 struct lua_State th; /* thread */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
194 };
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
195
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
196
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
197 #define gch(o) (&(o)->gch)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
198
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
199 /* macros to convert a GCObject into a specific value */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
200 #define rawgco2ts(o) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
201 check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
202 #define gco2ts(o) (&rawgco2ts(o)->tsv)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
203 #define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
204 #define gco2u(o) (&rawgco2u(o)->uv)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
205 #define gco2lcl(o) check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
206 #define gco2ccl(o) check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
207 #define gco2cl(o) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
208 check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
209 #define gco2t(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
210 #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
211 #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
212 #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
213
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
214 /* macro to convert any Lua object into a GCObject */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
215 #define obj2gco(v) (cast(GCObject *, (v)))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
216
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
217
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
218 /* actual number of total bytes allocated */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
219 #define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
220
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
221 LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
222 LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
223 LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
224 LUAI_FUNC void luaE_freeCI (lua_State *L);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
225
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
226
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
227 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
228