22#define LUA_TPROTO LUA_NUMTAGS
23#define LUA_TUPVAL (LUA_NUMTAGS+1)
24#define LUA_TDEADKEY (LUA_NUMTAGS+2)
29#define LUA_TOTALTAGS (LUA_TUPVAL+2)
39#define VARBITS (3 << 4)
50#define LUA_TLCL (LUA_TFUNCTION | (0 << 4))
51#define LUA_TLCF (LUA_TFUNCTION | (1 << 4))
52#define LUA_TCCL (LUA_TFUNCTION | (2 << 4))
56#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4))
57#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4))
61#define BIT_ISCOLLECTABLE (1 << 6)
64#define ctb(t) ((t) | BIT_ISCOLLECTABLE)
77#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
95#define numfield lua_Number n;
104#define TValuefields Value value_; int tt_
110#define NILCONSTANT {NULL}, LUA_TNIL
113#define val_(o) ((o)->value_)
114#define num_(o) (val_(o).n)
118#define rttype(o) ((o)->tt_)
121#define novariant(x) ((x) & 0x0F)
124#define ttype(o) (rttype(o) & 0x3F)
127#define ttypenv(o) (novariant(rttype(o)))
131#define checktag(o,t) (rttype(o) == (t))
132#define checktype(o,t) (ttypenv(o) == (t))
133#define ttisnumber(o) checktag((o), LUA_TNUMBER)
134#define ttisnil(o) checktag((o), LUA_TNIL)
135#define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
136#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
137#define ttisstring(o) checktype((o), LUA_TSTRING)
138#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
139#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
140#define ttistable(o) checktag((o), ctb(LUA_TTABLE))
141#define ttisfunction(o) checktype(o, LUA_TFUNCTION)
142#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION)
143#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))
144#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
145#define ttislcf(o) checktag((o), LUA_TLCF)
146#define ttisuserdata(o) checktag((o), ctb(LUA_TUSERDATA))
147#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))
148#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY)
150#define ttisequal(o1,o2) (rttype(o1) == rttype(o2))
153#define nvalue(o) check_exp(ttisnumber(o), num_(o))
154#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
155#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
156#define rawtsvalue(o) check_exp(ttisstring(o), &val_(o).gc->ts)
157#define tsvalue(o) (&rawtsvalue(o)->tsv)
158#define rawuvalue(o) check_exp(ttisuserdata(o), &val_(o).gc->u)
159#define uvalue(o) (&rawuvalue(o)->uv)
160#define clvalue(o) check_exp(ttisclosure(o), &val_(o).gc->cl)
161#define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l)
162#define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c)
163#define fvalue(o) check_exp(ttislcf(o), val_(o).f)
164#define hvalue(o) check_exp(ttistable(o), &val_(o).gc->h)
165#define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
166#define thvalue(o) check_exp(ttisthread(o), &val_(o).gc->th)
168#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc))
170#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
173#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
177#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt)
179#define checkliveness(g,obj) \
180 lua_longassert(!iscollectable(obj) || \
181 (righttt(obj) && !isdead(g,gcvalue(obj))))
185#define settt_(o,t) ((o)->tt_=(t))
187#define setnvalue(obj,x) \
188 { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); }
190#define setnilvalue(obj) settt_(obj, LUA_TNIL)
192#define setfvalue(obj,x) \
193 { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
195#define setpvalue(obj,x) \
196 { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
198#define setbvalue(obj,x) \
199 { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
201#define setgcovalue(L,obj,x) \
202 { TValue *io=(obj); GCObject *i_g=(x); \
203 val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); }
205#define setsvalue(L,obj,x) \
206 { TValue *io=(obj); \
208 val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \
209 checkliveness(G(L),io); }
211#define setuvalue(L,obj,x) \
212 { TValue *io=(obj); \
213 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \
214 checkliveness(G(L),io); }
216#define setthvalue(L,obj,x) \
217 { TValue *io=(obj); \
218 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \
219 checkliveness(G(L),io); }
221#define setclLvalue(L,obj,x) \
222 { TValue *io=(obj); \
223 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \
224 checkliveness(G(L),io); }
226#define setclCvalue(L,obj,x) \
227 { TValue *io=(obj); \
228 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \
229 checkliveness(G(L),io); }
231#define sethvalue(L,obj,x) \
232 { TValue *io=(obj); \
233 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \
234 checkliveness(G(L),io); }
236#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY)
240#define setobj(L,obj1,obj2) \
241 { const TValue *io2=(obj2); TValue *io1=(obj1); \
242 io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
243 checkliveness(G(L),io1); }
251#define setobjs2s setobj
253#define setobj2s setobj
254#define setsvalue2s setsvalue
255#define sethvalue2s sethvalue
256#define setptvalue2s setptvalue
258#define setobjt2t setobj
260#define setobj2t setobj
262#define setobj2n setobj
263#define setsvalue2n setsvalue
267#define luai_checknum(L,o,c) { }
275#if defined(LUA_NANTRICK)
288#if !defined(LUA_IEEEENDIAN)
289#error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN'
293#define NNMARK 0x7FF7A500
294#define NNMASK 0x7FFFFF00
299#if (LUA_IEEEENDIAN == 0)
302#define TValuefields \
303 union { struct { Value v__; int tt__; } i; double d__; } u
304#define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}}
306#define v_(o) ((o)->u.i.v__)
307#define d_(o) ((o)->u.d__)
308#define tt_(o) ((o)->u.i.tt__)
313#define TValuefields \
314 union { struct { int tt__; Value v__; } i; double d__; } u
315#define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}}
317#define v_(o) ((o)->u.i.v__)
318#define d_(o) ((o)->u.d__)
319#define tt_(o) ((o)->u.i.tt__)
338#define ttisnumber(o) ((tt_(o) & NNMASK) != NNMARK)
340#define tag2tt(t) (NNMARK | (t))
343#define rttype(o) (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff)
346#define settt_(o,t) (tt_(o) = tag2tt(t))
349#define setnvalue(obj,x) \
350 { TValue *io_=(obj); num_(io_)=(x); lua_assert(ttisnumber(io_)); }
353#define setobj(L,obj1,obj2) \
354 { const TValue *o2_=(obj2); TValue *o1_=(obj1); \
356 checkliveness(G(L),o1_); }
365#define checktag(o,t) (tt_(o) == tag2tt(t))
366#define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS))
369#define ttisequal(o1,o2) \
370 (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2)))
374#define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; }
422#define getstr(ts) cast(const char *, (ts) + 1)
425#define svalue(o) getstr(rawtsvalue(o))
467typedef struct Proto {
496typedef struct UpVal {
513#define ClosureHeader \
514 CommonHeader; lu_byte nupvalues; GCObject *gclist
536#define isLfunction(o) ttisLclosure(o)
538#define getproto(o) (clLvalue(o)->p)
560typedef struct Table {
577#define lmod(s,size) \
578 (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
581#define twoto(x) (1<<(x))
582#define sizenode(t) (twoto((t)->lsizenode))
588#define luaO_nilobject (&luaO_nilobject_)
int(* lua_CFunction)(lua_State *L)
LUAI_FUNC void luaO_chunkid(char *out, const char *source, size_t len)
LUAI_FUNC const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
LUAI_FUNC int luaO_hexavalue(int c)
LUAI_FUNC int luaO_fb2int(int x)
struct Upvaldesc Upvaldesc
LUAI_DDEC const TValue luaO_nilobject_
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)
LUAI_FUNC int luaO_ceillog2(unsigned int x)
LUAI_FUNC int luaO_int2fb(unsigned int x)
LUAI_FUNC int luaO_str2d(const char *s, size_t len, lua_Number *result)
CURL_EXTERN CURLMcode curl_socket_t s