21 #define LUA_TPROTO LUA_NUMTAGS
22 #define LUA_TUPVAL (LUA_NUMTAGS+1)
23 #define LUA_TDEADKEY (LUA_NUMTAGS+2)
28 #define LUA_TOTALTAGS (LUA_TUPVAL+2)
38 #define VARBITS (3 << 4)
49 #define LUA_TLCL (LUA_TFUNCTION | (0 << 4))
50 #define LUA_TLCF (LUA_TFUNCTION | (1 << 4))
51 #define LUA_TCCL (LUA_TFUNCTION | (2 << 4))
55 #define LUA_TSHRSTR (LUA_TSTRING | (0 << 4))
56 #define LUA_TLNGSTR (LUA_TSTRING | (1 << 4))
60 #define BIT_ISCOLLECTABLE (1 << 6)
63 #define ctb(t) ((t) | BIT_ISCOLLECTABLE)
76 #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
94 #define numfield lua_Number n;
103 #define TValuefields Value value_; int tt_
109 #define NILCONSTANT {NULL}, LUA_TNIL
112 #define val_(o) ((o)->value_)
113 #define num_(o) (val_(o).n)
117 #define rttype(o) ((o)->tt_)
120 #define novariant(x) ((x) & 0x0F)
123 #define ttype(o) (rttype(o) & 0x3F)
126 #define ttypenv(o) (novariant(rttype(o)))
130 #define checktag(o,t) (rttype(o) == (t))
131 #define checktype(o,t) (ttypenv(o) == (t))
132 #define ttisnumber(o) checktag((o), LUA_TNUMBER)
133 #define ttisnil(o) checktag((o), LUA_TNIL)
134 #define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
135 #define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
136 #define ttisstring(o) checktype((o), LUA_TSTRING)
137 #define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
138 #define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
139 #define ttistable(o) checktag((o), ctb(LUA_TTABLE))
140 #define ttisfunction(o) checktype(o, LUA_TFUNCTION)
141 #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION)
142 #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))
143 #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
144 #define ttislcf(o) checktag((o), LUA_TLCF)
145 #define ttisuserdata(o) checktag((o), ctb(LUA_TUSERDATA))
146 #define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))
147 #define ttisdeadkey(o) checktag((o), LUA_TDEADKEY)
149 #define ttisequal(o1,o2) (rttype(o1) == rttype(o2))
152 #define nvalue(o) check_exp(ttisnumber(o), num_(o))
153 #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
154 #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
155 #define rawtsvalue(o) check_exp(ttisstring(o), &val_(o).gc->ts)
156 #define tsvalue(o) (&rawtsvalue(o)->tsv)
157 #define rawuvalue(o) check_exp(ttisuserdata(o), &val_(o).gc->u)
158 #define uvalue(o) (&rawuvalue(o)->uv)
159 #define clvalue(o) check_exp(ttisclosure(o), &val_(o).gc->cl)
160 #define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l)
161 #define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c)
162 #define fvalue(o) check_exp(ttislcf(o), val_(o).f)
163 #define hvalue(o) check_exp(ttistable(o), &val_(o).gc->h)
164 #define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
165 #define thvalue(o) check_exp(ttisthread(o), &val_(o).gc->th)
167 #define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc))
169 #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
172 #define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
176 #define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt)
178 #define checkliveness(g,obj) \
179 lua_longassert(!iscollectable(obj) || \
180 (righttt(obj) && !isdead(g,gcvalue(obj))))
184 #define settt_(o,t) ((o)->tt_=(t))
186 #define setnvalue(obj,x) \
187 { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); }
189 #define setnilvalue(obj) settt_(obj, LUA_TNIL)
191 #define setfvalue(obj,x) \
192 { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
194 #define setpvalue(obj,x) \
195 { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
197 #define setbvalue(obj,x) \
198 { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
200 #define setgcovalue(L,obj,x) \
201 { TValue *io=(obj); GCObject *i_g=(x); \
202 val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); }
204 #define setsvalue(L,obj,x) \
205 { TValue *io=(obj); \
207 val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \
208 checkliveness(G(L),io); }
210 #define setuvalue(L,obj,x) \
211 { TValue *io=(obj); \
212 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \
213 checkliveness(G(L),io); }
215 #define setthvalue(L,obj,x) \
216 { TValue *io=(obj); \
217 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \
218 checkliveness(G(L),io); }
220 #define setclLvalue(L,obj,x) \
221 { TValue *io=(obj); \
222 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \
223 checkliveness(G(L),io); }
225 #define setclCvalue(L,obj,x) \
226 { TValue *io=(obj); \
227 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \
228 checkliveness(G(L),io); }
230 #define sethvalue(L,obj,x) \
231 { TValue *io=(obj); \
232 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \
233 checkliveness(G(L),io); }
235 #define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY)
239 #define setobj(L,obj1,obj2) \
240 { const TValue *io2=(obj2); TValue *io1=(obj1); \
241 io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
242 checkliveness(G(L),io1); }
250 #define setobjs2s setobj
252 #define setobj2s setobj
253 #define setsvalue2s setsvalue
254 #define sethvalue2s sethvalue
255 #define setptvalue2s setptvalue
257 #define setobjt2t setobj
259 #define setobj2t setobj
261 #define setobj2n setobj
262 #define setsvalue2n setsvalue
266 #define luai_checknum(L,o,c) { }
274 #if defined(LUA_NANTRICK)
287 #if !defined(LUA_IEEEENDIAN)
288 #error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN'
292 #define NNMARK 0x7FF7A500
293 #define NNMASK 0x7FFFFF00
298 #if (LUA_IEEEENDIAN == 0)
301 #define TValuefields \
302 union { struct { Value v__; int tt__; } i; double d__; } u
303 #define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}}
305 #define v_(o) ((o)->u.i.v__)
306 #define d_(o) ((o)->u.d__)
307 #define tt_(o) ((o)->u.i.tt__)
312 #define TValuefields \
313 union { struct { int tt__; Value v__; } i; double d__; } u
314 #define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}}
316 #define v_(o) ((o)->u.i.v__)
317 #define d_(o) ((o)->u.d__)
318 #define tt_(o) ((o)->u.i.tt__)
327 #define val_(o) v_(o)
329 #define num_(o) d_(o)
337 #define ttisnumber(o) ((tt_(o) & NNMASK) != NNMARK)
339 #define tag2tt(t) (NNMARK | (t))
342 #define rttype(o) (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff)
345 #define settt_(o,t) (tt_(o) = tag2tt(t))
348 #define setnvalue(obj,x) \
349 { TValue *io_=(obj); num_(io_)=(x); lua_assert(ttisnumber(io_)); }
352 #define setobj(L,obj1,obj2) \
353 { const TValue *o2_=(obj2); TValue *o1_=(obj1); \
355 checkliveness(G(L),o1_); }
364 #define checktag(o,t) (tt_(o) == tag2tt(t))
365 #define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS))
368 #define ttisequal(o1,o2) \
369 (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2)))
373 #define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; }
421 #define getstr(ts) cast(const char *, (ts) + 1)
424 #define svalue(o) getstr(rawtsvalue(o))
512 #define ClosureHeader \
513 CommonHeader; lu_byte nupvalues; GCObject *gclist
535 #define isLfunction(o) ttisLclosure(o)
537 #define getproto(o) (clLvalue(o)->p)
576 #define lmod(s,size) \
577 (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
580 #define twoto(x) (1<<(x))
581 #define sizenode(t) (twoto((t)->lsizenode))
587 #define luaO_nilobject (&luaO_nilobject_)
GLfloat GLfloat GLfloat v2
LUAI_FUNC int luaO_hexavalue(int c)
int(* lua_CFunction)(lua_State *L)
LUAI_FUNC int luaO_int2fb(unsigned int x)
struct Upvaldesc Upvaldesc
LUAI_FUNC int luaO_str2d(const char *s, size_t len, lua_Number *result)
LUAI_FUNC const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)
LUAI_FUNC lua_Number luaO_arith(int op, lua_Number v1, lua_Number v2)
GLint GLint GLint GLint GLint x
LUAI_FUNC int luaO_ceillog2(unsigned int x)
LUAI_FUNC int luaO_fb2int(int x)
LUAI_FUNC const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
LUAI_DDEC const TValue luaO_nilobject_
GLsizei GLsizei GLchar * source
LUAI_FUNC void luaO_chunkid(char *out, const char *source, size_t len)
LUAI_USER_ALIGNMENT_T L_Umaxalign