22 #define LUA_TUPVAL LUA_NUMTYPES 23 #define LUA_TPROTO (LUA_NUMTYPES+1) 29 #define LUA_TOTALTYPES (LUA_TPROTO + 2) 40 #define makevariant(t,v) ((t) | ((v) << 4)) 61 #define TValuefields Value value_; lu_byte tt_ 68 #define val_(o) ((o)->value_) 69 #define valraw(o) (&val_(o)) 73 #define rawtt(o) ((o)->tt_) 76 #define novariant(t) ((t) & 0x0F) 79 #define withvariant(t) ((t) & 0x3F) 80 #define ttypetag(o) withvariant(rawtt(o)) 83 #define ttype(o) (novariant(rawtt(o))) 87 #define checktag(o,t) (rawtt(o) == (t)) 88 #define checktype(o,t) (ttype(o) == (t)) 94 #define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt) 102 #define checkliveness(L,obj) \ 103 ((void)L, lua_longassert(!iscollectable(obj) || \ 104 (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))) 110 #define settt_(o,t) ((o)->tt_=(t)) 114 #define setobj(L,obj1,obj2) \ 115 { TValue *io1=(obj1); const TValue *io2=(obj2); \ 116 io1->value_ = io2->value_; settt_(io1, io2->tt_); \ 117 checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); } 125 #define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2)) 127 #define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2) 129 #define setobjt2t setobj 131 #define setobj2n setobj 133 #define setobj2t setobj 148 #define s2v(o) (&(o)->val) 159 #define LUA_VNIL makevariant(LUA_TNIL, 0) 162 #define LUA_VEMPTY makevariant(LUA_TNIL, 1) 165 #define LUA_VABSTKEY makevariant(LUA_TNIL, 2) 169 #define ttisnil(v) checktype((v), LUA_TNIL) 173 #define ttisstrictnil(o) checktag((o), LUA_VNIL) 176 #define setnilvalue(obj) settt_(obj, LUA_VNIL) 179 #define isabstkey(v) checktag((v), LUA_VABSTKEY) 185 #define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v)) 193 #define isempty(v) ttisnil(v) 197 #define ABSTKEYCONSTANT {NULL}, LUA_VABSTKEY 201 #define setempty(v) settt_(v, LUA_VEMPTY) 215 #define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0) 216 #define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1) 218 #define ttisboolean(o) checktype((o), LUA_TBOOLEAN) 219 #define ttisfalse(o) checktag((o), LUA_VFALSE) 220 #define ttistrue(o) checktag((o), LUA_VTRUE) 223 #define l_isfalse(o) (ttisfalse(o) || ttisnil(o)) 226 #define setbfvalue(obj) settt_(obj, LUA_VFALSE) 227 #define setbtvalue(obj) settt_(obj, LUA_VTRUE) 238 #define LUA_VTHREAD makevariant(LUA_TTHREAD, 0) 240 #define ttisthread(o) checktag((o), ctb(LUA_VTHREAD)) 242 #define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) 244 #define setthvalue(L,obj,x) \ 245 { TValue *io = (obj); lua_State *x_ = (x); \ 246 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTHREAD)); \ 247 checkliveness(L,io); } 249 #define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t) 264 #define CommonHeader struct GCObject *next; lu_byte tt; lu_byte marked 274 #define BIT_ISCOLLECTABLE (1 << 6) 276 #define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE) 279 #define ctb(t) ((t) | BIT_ISCOLLECTABLE) 281 #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) 283 #define gcvalueraw(v) ((v).gc) 285 #define setgcovalue(L,obj,x) \ 286 { TValue *io = (obj); GCObject *i_g=(x); \ 287 val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } 299 #define LUA_VNUMINT makevariant(LUA_TNUMBER, 0) 300 #define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1) 302 #define ttisnumber(o) checktype((o), LUA_TNUMBER) 303 #define ttisfloat(o) checktag((o), LUA_VNUMFLT) 304 #define ttisinteger(o) checktag((o), LUA_VNUMINT) 306 #define nvalue(o) check_exp(ttisnumber(o), \ 307 (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) 308 #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) 309 #define ivalue(o) check_exp(ttisinteger(o), val_(o).i) 311 #define fltvalueraw(v) ((v).n) 312 #define ivalueraw(v) ((v).i) 314 #define setfltvalue(obj,x) \ 315 { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_VNUMFLT); } 317 #define chgfltvalue(obj,x) \ 318 { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } 320 #define setivalue(obj,x) \ 321 { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_VNUMINT); } 323 #define chgivalue(obj,x) \ 324 { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } 336 #define LUA_VSHRSTR makevariant(LUA_TSTRING, 0) 337 #define LUA_VLNGSTR makevariant(LUA_TSTRING, 1) 339 #define ttisstring(o) checktype((o), LUA_TSTRING) 340 #define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR)) 341 #define ttislngstring(o) checktag((o), ctb(LUA_VLNGSTR)) 343 #define tsvalueraw(v) (gco2ts((v).gc)) 345 #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) 347 #define setsvalue(L,obj,x) \ 348 { TValue *io = (obj); TString *x_ = (x); \ 349 val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ 350 checkliveness(L,io); } 353 #define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s) 356 #define setsvalue2n setsvalue 379 #define getstr(ts) ((ts)->contents) 383 #define svalue(o) getstr(tsvalue(o)) 386 #define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen) 389 #define vslen(o) tsslen(tsvalue(o)) 405 #define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0) 407 #define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0) 409 #define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA) 410 #define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA)) 412 #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) 413 #define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) 415 #define pvalueraw(v) ((v).p) 417 #define setpvalue(obj,x) \ 418 { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_VLIGHTUSERDATA); } 420 #define setuvalue(L,obj,x) \ 421 { TValue *io = (obj); Udata *x_ = (x); \ 422 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VUSERDATA)); \ 423 checkliveness(L,io); } 466 #define udatamemoffset(nuv) \ 467 ((nuv) == 0 ? offsetof(Udata0, bindata) \ 468 : offsetof(Udata, uv) + (sizeof(UValue) * (nuv))) 471 #define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue)) 474 #define sizeudata(nuv,nb) (udatamemoffset(nuv) + (nb)) 485 #define LUA_VPROTO makevariant(LUA_TPROTO, 0) 562 #define LUA_VUPVAL makevariant(LUA_TUPVAL, 0) 566 #define LUA_VLCL makevariant(LUA_TFUNCTION, 0) 567 #define LUA_VLCF makevariant(LUA_TFUNCTION, 1) 568 #define LUA_VCCL makevariant(LUA_TFUNCTION, 2) 570 #define ttisfunction(o) checktype(o, LUA_TFUNCTION) 571 #define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_VLCL) 572 #define ttisLclosure(o) checktag((o), ctb(LUA_VLCL)) 573 #define ttislcf(o) checktag((o), LUA_VLCF) 574 #define ttisCclosure(o) checktag((o), ctb(LUA_VCCL)) 576 #define isLfunction(o) ttisLclosure(o) 578 #define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) 579 #define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) 580 #define fvalue(o) check_exp(ttislcf(o), val_(o).f) 581 #define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) 583 #define fvalueraw(v) ((v).f) 585 #define setclLvalue(L,obj,x) \ 586 { TValue *io = (obj); LClosure *x_ = (x); \ 587 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VLCL)); \ 588 checkliveness(L,io); } 590 #define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl) 592 #define setfvalue(obj,x) \ 593 { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_VLCF); } 595 #define setclCvalue(L,obj,x) \ 596 { TValue *io = (obj); CClosure *x_ = (x); \ 597 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VCCL)); \ 598 checkliveness(L,io); } 619 #define ClosureHeader \ 620 CommonHeader; lu_byte nupvalues; GCObject *gclist 642 #define getproto(o) (clLvalue(o)->p) 653 #define LUA_VTABLE makevariant(LUA_TTABLE, 0) 655 #define ttistable(o) checktag((o), ctb(LUA_VTABLE)) 657 #define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) 659 #define sethvalue(L,obj,x) \ 660 { TValue *io = (obj); Table *x_ = (x); \ 661 val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTABLE)); \ 662 checkliveness(L,io); } 664 #define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h) 686 #define setnodekey(L,node,obj) \ 687 { Node *n_=(node); const TValue *io_=(obj); \ 688 n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \ 689 checkliveness(L,io_); } 693 #define getnodekey(L,obj,node) \ 694 { TValue *io_=(obj); const Node *n_=(node); \ 695 io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \ 696 checkliveness(L,io_); } 706 #define BITRAS (1 << 7) 707 #define isrealasize(t) (!((t)->flags & BITRAS)) 708 #define setrealasize(t) ((t)->flags &= cast_byte(~BITRAS)) 709 #define setnorealasize(t) ((t)->flags |= BITRAS) 728 #define keytt(node) ((node)->u.key_tt) 729 #define keyval(node) ((node)->u.key_val) 731 #define keyisnil(node) (keytt(node) == LUA_TNIL) 732 #define keyisinteger(node) (keytt(node) == LUA_VNUMINT) 733 #define keyival(node) (keyval(node).i) 734 #define keyisshrstr(node) (keytt(node) == ctb(LUA_VSHRSTR)) 735 #define keystrval(node) (gco2ts(keyval(node).gc)) 737 #define setnilkey(node) (keytt(node) = LUA_TNIL) 739 #define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE) 741 #define gckey(n) (keyval(n).gc) 742 #define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL) 752 #define setdeadkey(n) (keytt(n) = LUA_TTABLE, gckey(n) = NULL) 761 #define lmod(s,size) \ 762 (check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1))))) 765 #define twoto(x) (1<<(x)) 766 #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
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)
struct UpVal::@22::@23 open
union StackValue StackValue
LUAI_FUNC void luaO_arith(lua_State *L, int op, const TValue *p1, const TValue *p2, StkId res)