22 #define LUA_TPROTO LUA_NUMTAGS 23 #define LUA_TDEADKEY (LUA_NUMTAGS+1) 28 #define LUA_TOTALTAGS (LUA_TPROTO + 2) 47 #define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) 48 #define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) 49 #define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) 53 #define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) 54 #define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) 58 #define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) 59 #define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) 63 #define BIT_ISCOLLECTABLE (1 << 6) 66 #define ctb(t) ((t) | BIT_ISCOLLECTABLE) 79 #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked 110 #define TValuefields Value value_; int tt_ 120 #define NILCONSTANT {NULL}, LUA_TNIL 123 #define val_(o) ((o)->value_) 127 #define rttype(o) ((o)->tt_) 130 #define novariant(x) ((x) & 0x0F) 133 #define ttype(o) (rttype(o) & 0x3F) 136 #define ttnov(o) (novariant(rttype(o))) 140 #define checktag(o,t) (rttype(o) == (t)) 141 #define checktype(o,t) (ttnov(o) == (t)) 142 #define ttisnumber(o) checktype((o), LUA_TNUMBER) 143 #define ttisfloat(o) checktag((o), LUA_TNUMFLT) 144 #define ttisinteger(o) checktag((o), LUA_TNUMINT) 145 #define ttisnil(o) checktag((o), LUA_TNIL) 146 #define ttisboolean(o) checktag((o), LUA_TBOOLEAN) 147 #define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) 148 #define ttisstring(o) checktype((o), LUA_TSTRING) 149 #define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) 150 #define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR)) 151 #define ttistable(o) checktag((o), ctb(LUA_TTABLE)) 152 #define ttisfunction(o) checktype(o, LUA_TFUNCTION) 153 #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) 154 #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) 155 #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) 156 #define ttislcf(o) checktag((o), LUA_TLCF) 157 #define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA)) 158 #define ttisthread(o) checktag((o), ctb(LUA_TTHREAD)) 159 #define ttisdeadkey(o) checktag((o), LUA_TDEADKEY) 163 #define ivalue(o) check_exp(ttisinteger(o), val_(o).i) 164 #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) 165 #define nvalue(o) check_exp(ttisnumber(o), \ 166 (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) 167 #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) 168 #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) 169 #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) 170 #define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) 171 #define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) 172 #define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) 173 #define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) 174 #define fvalue(o) check_exp(ttislcf(o), val_(o).f) 175 #define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) 176 #define bvalue(o) check_exp(ttisboolean(o), val_(o).b) 177 #define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) 179 #define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc)) 181 #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) 184 #define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) 188 #define righttt(obj) (ttype(obj) == gcvalue(obj)->tt) 190 #define checkliveness(L,obj) \ 191 lua_longassert(!iscollectable(obj) || \ 192 (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj))))) 196 #define settt_(o,t) ((o)->tt_=(t)) 198 #define setfltvalue(obj,x) \ 199 { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); } 201 #define chgfltvalue(obj,x) \ 202 { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } 204 #define setivalue(obj,x) \ 205 { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); } 207 #define chgivalue(obj,x) \ 208 { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } 210 #define setnilvalue(obj) settt_(obj, LUA_TNIL) 212 #define setfvalue(obj,x) \ 213 { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); } 215 #define setpvalue(obj,x) \ 216 { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); } 218 #define setbvalue(obj,x) \ 219 { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); } 221 #define setgcovalue(L,obj,x) \ 222 { TValue *io = (obj); GCObject *i_g=(x); \ 223 val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } 225 #define setsvalue(L,obj,x) \ 226 { TValue *io = (obj); TString *x_ = (x); \ 227 val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ 228 checkliveness(L,io); } 230 #define setuvalue(L,obj,x) \ 231 { TValue *io = (obj); Udata *x_ = (x); \ 232 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \ 233 checkliveness(L,io); } 235 #define setthvalue(L,obj,x) \ 236 { TValue *io = (obj); lua_State *x_ = (x); \ 237 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \ 238 checkliveness(L,io); } 240 #define setclLvalue(L,obj,x) \ 241 { TValue *io = (obj); LClosure *x_ = (x); \ 242 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \ 243 checkliveness(L,io); } 245 #define setclCvalue(L,obj,x) \ 246 { TValue *io = (obj); CClosure *x_ = (x); \ 247 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \ 248 checkliveness(L,io); } 250 #define sethvalue(L,obj,x) \ 251 { TValue *io = (obj); Table *x_ = (x); \ 252 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \ 253 checkliveness(L,io); } 255 #define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) 259 #define setobj(L,obj1,obj2) \ 260 { TValue *io1=(obj1); *io1 = *(obj2); \ 261 (void)L; checkliveness(L,io1); } 269 #define setobjs2s setobj 271 #define setobj2s setobj 272 #define setsvalue2s setsvalue 273 #define sethvalue2s sethvalue 274 #define setptvalue2s setptvalue 276 #define setobjt2t setobj 278 #define setobj2n setobj 279 #define setsvalue2n setsvalue 282 #define setobj2t(L,o1,o2) ((void)L, *(o1)=*(o2), checkliveness(L,(o1))) 329 check_exp(sizeof((ts)->extra), cast(char *, (ts)) + sizeof(UTString)) 333 #define svalue(o) getstr(tsvalue(o)) 336 #define tsslen(s) ((s)->tt == LUA_TSHRSTR ? (s)->shrlen : (s)->u.lnglen) 339 #define vslen(o) tsslen(tsvalue(o)) 349 struct Table *metatable;
368 #define getudatamem(u) \ 369 check_exp(sizeof((u)->ttuv_), (cast(char*, (u)) + sizeof(UUdata))) 371 #define setuservalue(L,u,o) \ 372 { const TValue *io=(o); Udata *iu = (u); \ 373 iu->user_ = io->value_; iu->ttuv_ = rttype(io); \ 374 checkliveness(L,io); } 377 #define getuservalue(L,u,o) \ 378 { TValue *io=(o); const Udata *iu = (u); \ 379 io->value_ = iu->user_; settt_(io, iu->ttuv_); \ 380 checkliveness(L,io); } 411 lu_byte maxstacksize;
436 typedef struct UpVal UpVal;
443 #define ClosureHeader \ 444 CommonHeader; lu_byte nupvalues; GCObject *gclist 466 #define isLfunction(o) ttisLclosure(o) 468 #define getproto(o) (clLvalue(o)->p) 485 #define setnodekey(L,key,obj) \ 486 { TKey *k_=(key); const TValue *io_=(obj); \ 487 k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ 488 (void)L; checkliveness(L,io_); } 501 unsigned int sizearray;
505 struct Table *metatable;
514 #define lmod(s,size) \ 515 (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1))))) 518 #define twoto(x) (1<<(x)) 519 #define sizenode(t) (twoto((t)->lsizenode)) 525 #define luaO_nilobject (&luaO_nilobject_) 528 LUAI_DDEC
const TValue luaO_nilobject_;
533 LUAI_FUNC
int luaO_int2fb (
unsigned int x);
534 LUAI_FUNC
int luaO_fb2int (
int x);
535 LUAI_FUNC
int luaO_utf8esc (
char *buff,
unsigned long x);
536 LUAI_FUNC
int luaO_ceillog2 (
unsigned int x);
539 LUAI_FUNC
size_t luaO_str2num (
const char *s,
TValue *o);
540 LUAI_FUNC
int luaO_hexavalue (
int c);
542 LUAI_FUNC
const char *luaO_pushvfstring (
lua_State *L,
const char *fmt,
544 LUAI_FUNC
const char *luaO_pushfstring (
lua_State *L,
const char *fmt, ...);
545 LUAI_FUNC
void luaO_chunkid (
char *out,
const char *source,
size_t len);
Definition: lobject.h:453
Definition: lobject.h:318
Definition: lobject.h:497
Definition: lobject.h:358
Definition: lobject.h:407
Definition: lobject.h:475
Definition: lobject.h:491
Definition: lobject.h:397
Definition: lobject.h:100
Definition: lobject.h:386
Definition: lobject.h:113
Definition: lobject.h:446
Definition: lobject.h:460
Definition: lobject.h:303
Definition: lobject.h:346