22 #define LUA_TUPVAL LUA_NUMTYPES 23 #define LUA_TPROTO (LUA_NUMTYPES+1) 24 #define LUA_TDEADKEY (LUA_NUMTYPES+2) 31 #define LUA_TOTALTYPES (LUA_TPROTO + 2) 42 #define makevariant(t,v) ((t) | ((v) << 4)) 63 #define TValuefields Value value_; lu_byte tt_ 70 #define val_(o) ((o)->value_) 71 #define valraw(o) (&val_(o)) 75 #define rawtt(o) ((o)->tt_) 78 #define novariant(t) ((t) & 0x0F) 81 #define withvariant(t) ((t) & 0x3F) 82 #define ttypetag(o) withvariant(rawtt(o)) 85 #define ttype(o) (novariant(rawtt(o))) 89 #define checktag(o,t) (rawtt(o) == (t)) 90 #define checktype(o,t) (ttype(o) == (t)) 96 #define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt) 104 #define checkliveness(L,obj) \ 105 ((void)L, lua_longassert(!iscollectable(obj) || \ 106 (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))) 112 #define settt_(o,t) ((o)->tt_=(t)) 116 #define setobj(L,obj1,obj2) \ 117 { TValue *io1=(obj1); const TValue *io2=(obj2); \ 118 io1->value_ = io2->value_; settt_(io1, io2->tt_); \ 119 checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); } 127 #define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2)) 129 #define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2) 131 #define setobjt2t setobj 133 #define setobj2n setobj 135 #define setobj2t setobj 159 #define s2v(o) (&(o)->val) 170 #define LUA_VNIL makevariant(LUA_TNIL, 0) 173 #define LUA_VEMPTY makevariant(LUA_TNIL, 1) 176 #define LUA_VABSTKEY makevariant(LUA_TNIL, 2) 180 #define ttisnil(v) checktype((v), LUA_TNIL) 184 #define ttisstrictnil(o) checktag((o), LUA_VNIL) 187 #define setnilvalue(obj) settt_(obj, LUA_VNIL) 190 #define isabstkey(v) checktag((v), LUA_VABSTKEY) 196 #define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v)) 204 #define isempty(v) ttisnil(v) 208 #define ABSTKEYCONSTANT {NULL}, LUA_VABSTKEY 212 #define setempty(v) settt_(v, LUA_VEMPTY) 226 #define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0) 227 #define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1) 229 #define ttisboolean(o) checktype((o), LUA_TBOOLEAN) 230 #define ttisfalse(o) checktag((o), LUA_VFALSE) 231 #define ttistrue(o) checktag((o), LUA_VTRUE) 234 #define l_isfalse(o) (ttisfalse(o) || ttisnil(o)) 237 #define setbfvalue(obj) settt_(obj, LUA_VFALSE) 238 #define setbtvalue(obj) settt_(obj, LUA_VTRUE) 249 #define LUA_VTHREAD makevariant(LUA_TTHREAD, 0) 251 #define ttisthread(o) checktag((o), ctb(LUA_VTHREAD)) 253 #define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) 255 #define setthvalue(L,obj,x) \ 256 { TValue *io = (obj); lua_State *x_ = (x); \ 257 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTHREAD)); \ 258 checkliveness(L,io); } 260 #define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t) 275 #define CommonHeader struct GCObject *next; lu_byte tt; lu_byte marked 285 #define BIT_ISCOLLECTABLE (1 << 6) 287 #define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE) 290 #define ctb(t) ((t) | BIT_ISCOLLECTABLE) 292 #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) 294 #define gcvalueraw(v) ((v).gc) 296 #define setgcovalue(L,obj,x) \ 297 { TValue *io = (obj); GCObject *i_g=(x); \ 298 val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } 310 #define LUA_VNUMINT makevariant(LUA_TNUMBER, 0) 311 #define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1) 313 #define ttisnumber(o) checktype((o), LUA_TNUMBER) 314 #define ttisfloat(o) checktag((o), LUA_VNUMFLT) 315 #define ttisinteger(o) checktag((o), LUA_VNUMINT) 317 #define nvalue(o) check_exp(ttisnumber(o), \ 318 (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) 319 #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) 320 #define ivalue(o) check_exp(ttisinteger(o), val_(o).i) 322 #define fltvalueraw(v) ((v).n) 323 #define ivalueraw(v) ((v).i) 325 #define setfltvalue(obj,x) \ 326 { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_VNUMFLT); } 328 #define chgfltvalue(obj,x) \ 329 { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } 331 #define setivalue(obj,x) \ 332 { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_VNUMINT); } 334 #define chgivalue(obj,x) \ 335 { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } 347 #define LUA_VSHRSTR makevariant(LUA_TSTRING, 0) 348 #define LUA_VLNGSTR makevariant(LUA_TSTRING, 1) 350 #define ttisstring(o) checktype((o), LUA_TSTRING) 351 #define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR)) 352 #define ttislngstring(o) checktag((o), ctb(LUA_VLNGSTR)) 354 #define tsvalueraw(v) (gco2ts((v).gc)) 356 #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) 358 #define setsvalue(L,obj,x) \ 359 { TValue *io = (obj); TString *x_ = (x); \ 360 val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ 361 checkliveness(L,io); } 364 #define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s) 367 #define setsvalue2n setsvalue 390 #define getstr(ts) ((ts)->contents) 394 #define svalue(o) getstr(tsvalue(o)) 397 #define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen) 400 #define vslen(o) tsslen(tsvalue(o)) 416 #define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0) 418 #define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0) 420 #define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA) 421 #define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA)) 423 #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) 424 #define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) 426 #define pvalueraw(v) ((v).p) 428 #define setpvalue(obj,x) \ 429 { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_VLIGHTUSERDATA); } 431 #define setuvalue(L,obj,x) \ 432 { TValue *io = (obj); Udata *x_ = (x); \ 433 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VUSERDATA)); \ 434 checkliveness(L,io); } 477 #define udatamemoffset(nuv) \ 478 ((nuv) == 0 ? offsetof(Udata0, bindata) \ 479 : offsetof(Udata, uv) + (sizeof(UValue) * (nuv))) 482 #define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue)) 485 #define sizeudata(nuv,nb) (udatamemoffset(nuv) + (nb)) 496 #define LUA_VPROTO makevariant(LUA_TPROTO, 0) 573 #define LUA_VUPVAL makevariant(LUA_TUPVAL, 0) 577 #define LUA_VLCL makevariant(LUA_TFUNCTION, 0) 578 #define LUA_VLCF makevariant(LUA_TFUNCTION, 1) 579 #define LUA_VCCL makevariant(LUA_TFUNCTION, 2) 581 #define ttisfunction(o) checktype(o, LUA_TFUNCTION) 582 #define ttisLclosure(o) checktag((o), ctb(LUA_VLCL)) 583 #define ttislcf(o) checktag((o), LUA_VLCF) 584 #define ttisCclosure(o) checktag((o), ctb(LUA_VCCL)) 585 #define ttisclosure(o) (ttisLclosure(o) || ttisCclosure(o)) 588 #define isLfunction(o) ttisLclosure(o) 590 #define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) 591 #define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) 592 #define fvalue(o) check_exp(ttislcf(o), val_(o).f) 593 #define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) 595 #define fvalueraw(v) ((v).f) 597 #define setclLvalue(L,obj,x) \ 598 { TValue *io = (obj); LClosure *x_ = (x); \ 599 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VLCL)); \ 600 checkliveness(L,io); } 602 #define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl) 604 #define setfvalue(obj,x) \ 605 { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_VLCF); } 607 #define setclCvalue(L,obj,x) \ 608 { TValue *io = (obj); CClosure *x_ = (x); \ 609 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VCCL)); \ 610 checkliveness(L,io); } 631 #define ClosureHeader \ 632 CommonHeader; lu_byte nupvalues; GCObject *gclist 654 #define getproto(o) (clLvalue(o)->p) 665 #define LUA_VTABLE makevariant(LUA_TTABLE, 0) 667 #define ttistable(o) checktag((o), ctb(LUA_VTABLE)) 669 #define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) 671 #define sethvalue(L,obj,x) \ 672 { TValue *io = (obj); Table *x_ = (x); \ 673 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTABLE)); \ 674 checkliveness(L,io); } 676 #define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h) 698 #define setnodekey(L,node,obj) \ 699 { Node *n_=(node); const TValue *io_=(obj); \ 700 n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \ 701 checkliveness(L,io_); } 705 #define getnodekey(L,obj,node) \ 706 { TValue *io_=(obj); const Node *n_=(node); \ 707 io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \ 708 checkliveness(L,io_); } 718 #define BITRAS (1 << 7) 719 #define isrealasize(t) (!((t)->flags & BITRAS)) 720 #define setrealasize(t) ((t)->flags &= cast_byte(~BITRAS)) 721 #define setnorealasize(t) ((t)->flags |= BITRAS) 740 #define keytt(node) ((node)->u.key_tt) 741 #define keyval(node) ((node)->u.key_val) 743 #define keyisnil(node) (keytt(node) == LUA_TNIL) 744 #define keyisinteger(node) (keytt(node) == LUA_VNUMINT) 745 #define keyival(node) (keyval(node).i) 746 #define keyisshrstr(node) (keytt(node) == ctb(LUA_VSHRSTR)) 747 #define keystrval(node) (gco2ts(keyval(node).gc)) 749 #define setnilkey(node) (keytt(node) = LUA_TNIL) 751 #define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE) 753 #define gckey(n) (keyval(n).gc) 754 #define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL) 763 #define setdeadkey(node) (keytt(node) = LUA_TDEADKEY) 764 #define keyisdead(node) (keytt(node) == LUA_TDEADKEY) 773 #define lmod(s,size) \ 774 (check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1))))) 777 #define twoto(x) (1<<(x)) 778 #define sizenode(t) (twoto((t)->lsizenode))
AbsLineInfo * abslineinfo
LUAI_FUNC size_t luaO_str2num(const char *s, TValue *o)
LUAI_FUNC int luaO_hexavalue(int c)
LUAI_FUNC void luaO_chunkid(char *out, const char *source, size_t srclen)
int(* lua_CFunction)(lua_State *L)
struct Upvaldesc Upvaldesc
struct UpVal::@4::@5 open
LUAI_FUNC const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)
LUAI_FUNC int luaO_rawarith(lua_State *L, int op, const TValue *p1, const TValue *p2, TValue *res)
LUAI_FUNC void luaO_tostring(lua_State *L, TValue *obj)
LUAI_FUNC int luaO_ceillog2(unsigned int x)
struct AbsLineInfo AbsLineInfo
LUAI_FUNC const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
LUAI_FUNC int luaO_utf8esc(char *buff, unsigned long x)
union StackValue StackValue
LUAI_FUNC void luaO_arith(lua_State *L, int op, const TValue *p1, const TValue *p2, StkId res)