2022-03-24 13:23:42 +00:00
|
|
|
# 1 "./lua/lobject.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef lobject_h
|
2022-03-24 13:23:42 +00:00
|
|
|
#define lobject_h
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "llimits.h"
|
|
|
|
#include "lua.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define LUA_TUPVAL LUA_NUMTYPES
|
|
|
|
#define LUA_TPROTO (LUA_NUMTYPES+1)
|
|
|
|
#define LUA_TDEADKEY (LUA_NUMTYPES+2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LUA_TOTALTYPES (LUA_TPROTO + 2)
|
|
|
|
# 42 "./lua/lobject.h"
|
|
|
|
#define makevariant(t,v) ((t) | ((v) << 4))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef union Value {
|
2022-03-24 13:23:42 +00:00
|
|
|
struct GCObject *gc;
|
|
|
|
void *p;
|
|
|
|
lua_CFunction f;
|
|
|
|
lua_Integer i;
|
|
|
|
lua_Number n;
|
2022-01-24 02:23:08 +00:00
|
|
|
} Value;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TValuefields Value value_; lu_byte tt_
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
typedef struct TValue {
|
|
|
|
TValuefields;
|
|
|
|
} TValue;
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define val_(o) ((o)->value_)
|
|
|
|
#define valraw(o) (val_(o))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define rawtt(o) ((o)->tt_)
|
|
|
|
|
|
|
|
|
|
|
|
#define novariant(t) ((t) & 0x0F)
|
|
|
|
|
|
|
|
|
|
|
|
#define withvariant(t) ((t) & 0x3F)
|
|
|
|
#define ttypetag(o) withvariant(rawtt(o))
|
|
|
|
|
|
|
|
|
|
|
|
#define ttype(o) (novariant(rawtt(o)))
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define checktag(o,t) (rawtt(o) == (t))
|
|
|
|
#define checktype(o,t) (ttype(o) == (t))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
|
|
#define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt)
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define checkliveness(L,obj) \
|
2022-03-24 13:23:42 +00:00
|
|
|
((void)L, lua_longassert(!iscollectable(obj) || \
|
|
|
|
(righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj))))))
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define settt_(o,t) ((o)->tt_=(t))
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define setobj(L,obj1,obj2) \
|
2022-03-24 13:23:42 +00:00
|
|
|
{ TValue *io1=(obj1); const TValue *io2=(obj2); \
|
2022-01-24 02:23:08 +00:00
|
|
|
io1->value_ = io2->value_; settt_(io1, io2->tt_); \
|
2022-03-24 13:23:42 +00:00
|
|
|
checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2))
|
|
|
|
|
|
|
|
#define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2)
|
|
|
|
|
|
|
|
#define setobjt2t setobj
|
|
|
|
|
|
|
|
#define setobj2n setobj
|
|
|
|
|
|
|
|
#define setobj2t setobj
|
|
|
|
# 146 "./lua/lobject.h"
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef union StackValue {
|
|
|
|
TValue val;
|
|
|
|
struct {
|
|
|
|
TValuefields;
|
|
|
|
unsigned short delta;
|
|
|
|
} tbclist;
|
|
|
|
} StackValue;
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef StackValue *StkId;
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define s2v(o) (&(o)->val)
|
|
|
|
# 170 "./lua/lobject.h"
|
|
|
|
#define LUA_VNIL makevariant(LUA_TNIL, 0)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define LUA_VEMPTY makevariant(LUA_TNIL, 1)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define LUA_VABSTKEY makevariant(LUA_TNIL, 2)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttisnil(v) checktype((v), LUA_TNIL)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttisstrictnil(o) checktag((o), LUA_VNIL)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setnilvalue(obj) settt_(obj, LUA_VNIL)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define isabstkey(v) checktag((v), LUA_VABSTKEY)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define isempty(v) ttisnil(v)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ABSTKEYCONSTANT {NULL}, LUA_VABSTKEY
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setempty(v) settt_(v, LUA_VEMPTY)
|
|
|
|
# 226 "./lua/lobject.h"
|
|
|
|
#define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0)
|
|
|
|
#define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttisboolean(o) checktype((o), LUA_TBOOLEAN)
|
|
|
|
#define ttisfalse(o) checktag((o), LUA_VFALSE)
|
|
|
|
#define ttistrue(o) checktag((o), LUA_VTRUE)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define l_isfalse(o) (ttisfalse(o) || ttisnil(o))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setbfvalue(obj) settt_(obj, LUA_VFALSE)
|
|
|
|
#define setbtvalue(obj) settt_(obj, LUA_VTRUE)
|
|
|
|
# 249 "./lua/lobject.h"
|
|
|
|
#define LUA_VTHREAD makevariant(LUA_TTHREAD, 0)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttisthread(o) checktag((o), ctb(LUA_VTHREAD))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define setthvalue(L,obj,x) \
|
|
|
|
{ TValue *io = (obj); lua_State *x_ = (x); \
|
|
|
|
val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTHREAD)); \
|
|
|
|
checkliveness(L,io); }
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t)
|
|
|
|
# 275 "./lua/lobject.h"
|
|
|
|
#define CommonHeader struct GCObject *next; lu_byte tt; lu_byte marked
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct GCObject {
|
|
|
|
CommonHeader;
|
|
|
|
} GCObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define BIT_ISCOLLECTABLE (1 << 6)
|
|
|
|
|
|
|
|
#define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ctb(t) ((t) | BIT_ISCOLLECTABLE)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
|
|
|
|
|
|
|
|
#define gcvalueraw(v) ((v).gc)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define setgcovalue(L,obj,x) \
|
|
|
|
{ TValue *io = (obj); GCObject *i_g=(x); \
|
|
|
|
val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); }
|
2022-03-24 13:23:42 +00:00
|
|
|
# 310 "./lua/lobject.h"
|
|
|
|
#define LUA_VNUMINT makevariant(LUA_TNUMBER, 0)
|
|
|
|
#define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttisnumber(o) checktype((o), LUA_TNUMBER)
|
|
|
|
#define ttisfloat(o) checktag((o), LUA_VNUMFLT)
|
|
|
|
#define ttisinteger(o) checktag((o), LUA_VNUMINT)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define nvalue(o) check_exp(ttisnumber(o), \
|
|
|
|
(ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o)))
|
|
|
|
#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n)
|
|
|
|
#define ivalue(o) check_exp(ttisinteger(o), val_(o).i)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define fltvalueraw(v) ((v).n)
|
|
|
|
#define ivalueraw(v) ((v).i)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define setfltvalue(obj,x) \
|
|
|
|
{ TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_VNUMFLT); }
|
|
|
|
|
|
|
|
#define chgfltvalue(obj,x) \
|
|
|
|
{ TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); }
|
|
|
|
|
|
|
|
#define setivalue(obj,x) \
|
|
|
|
{ TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_VNUMINT); }
|
|
|
|
|
|
|
|
#define chgivalue(obj,x) \
|
|
|
|
{ TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); }
|
2022-03-24 13:23:42 +00:00
|
|
|
# 347 "./lua/lobject.h"
|
|
|
|
#define LUA_VSHRSTR makevariant(LUA_TSTRING, 0)
|
|
|
|
#define LUA_VLNGSTR makevariant(LUA_TSTRING, 1)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttisstring(o) checktype((o), LUA_TSTRING)
|
|
|
|
#define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR))
|
|
|
|
#define ttislngstring(o) checktag((o), ctb(LUA_VLNGSTR))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define tsvalueraw(v) (gco2ts((v).gc))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define setsvalue(L,obj,x) \
|
|
|
|
{ TValue *io = (obj); TString *x_ = (x); \
|
|
|
|
val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \
|
|
|
|
checkliveness(L,io); }
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s)
|
|
|
|
|
|
|
|
|
|
|
|
#define setsvalue2n setsvalue
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct TString {
|
|
|
|
CommonHeader;
|
2022-03-24 13:23:42 +00:00
|
|
|
lu_byte extra;
|
|
|
|
lu_byte shrlen;
|
2022-01-24 02:23:08 +00:00
|
|
|
unsigned int hash;
|
|
|
|
union {
|
2022-03-24 13:23:42 +00:00
|
|
|
size_t lnglen;
|
|
|
|
struct TString *hnext;
|
2022-01-24 02:23:08 +00:00
|
|
|
} u;
|
|
|
|
char contents[1];
|
|
|
|
} TString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define getstr(ts) ((ts)->contents)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define svalue(o) getstr(tsvalue(o))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define vslen(o) tsslen(tsvalue(o))
|
|
|
|
# 416 "./lua/lobject.h"
|
|
|
|
#define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA)
|
|
|
|
#define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
|
|
|
|
#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc))
|
|
|
|
|
|
|
|
#define pvalueraw(v) ((v).p)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define setpvalue(obj,x) \
|
|
|
|
{ TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_VLIGHTUSERDATA); }
|
|
|
|
|
|
|
|
#define setuvalue(L,obj,x) \
|
|
|
|
{ TValue *io = (obj); Udata *x_ = (x); \
|
|
|
|
val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VUSERDATA)); \
|
|
|
|
checkliveness(L,io); }
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef union UValue {
|
|
|
|
TValue uv;
|
2022-03-24 13:23:42 +00:00
|
|
|
LUAI_MAXALIGN;
|
2022-01-24 02:23:08 +00:00
|
|
|
} UValue;
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef struct Udata {
|
|
|
|
CommonHeader;
|
2022-03-24 13:23:42 +00:00
|
|
|
unsigned short nuvalue;
|
|
|
|
size_t len;
|
2022-01-24 02:23:08 +00:00
|
|
|
struct Table *metatable;
|
|
|
|
GCObject *gclist;
|
2022-03-24 13:23:42 +00:00
|
|
|
UValue uv[1];
|
2022-01-24 02:23:08 +00:00
|
|
|
} Udata;
|
2022-03-24 13:23:42 +00:00
|
|
|
# 467 "./lua/lobject.h"
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef struct Udata0 {
|
|
|
|
CommonHeader;
|
2022-03-24 13:23:42 +00:00
|
|
|
unsigned short nuvalue;
|
|
|
|
size_t len;
|
2022-01-24 02:23:08 +00:00
|
|
|
struct Table *metatable;
|
|
|
|
union {LUAI_MAXALIGN;} bindata;
|
|
|
|
} Udata0;
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
#define udatamemoffset(nuv) \
|
2022-03-24 13:23:42 +00:00
|
|
|
((nuv) == 0 ? offsetof(Udata0, bindata) \
|
2022-01-24 02:23:08 +00:00
|
|
|
: offsetof(Udata, uv) + (sizeof(UValue) * (nuv)))
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue))
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define sizeudata(nuv,nb) (udatamemoffset(nuv) + (nb))
|
|
|
|
# 496 "./lua/lobject.h"
|
|
|
|
#define LUA_VPROTO makevariant(LUA_TPROTO, 0)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct Upvaldesc {
|
2022-03-24 13:23:42 +00:00
|
|
|
TString *name;
|
|
|
|
lu_byte instack;
|
|
|
|
lu_byte idx;
|
|
|
|
lu_byte kind;
|
2022-01-24 02:23:08 +00:00
|
|
|
} Upvaldesc;
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef struct LocVar {
|
|
|
|
TString *varname;
|
2022-03-24 13:23:42 +00:00
|
|
|
int startpc;
|
|
|
|
int endpc;
|
2022-01-24 02:23:08 +00:00
|
|
|
} LocVar;
|
2022-03-24 13:23:42 +00:00
|
|
|
# 531 "./lua/lobject.h"
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef struct AbsLineInfo {
|
|
|
|
int pc;
|
|
|
|
int line;
|
|
|
|
} AbsLineInfo;
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef struct Proto {
|
|
|
|
CommonHeader;
|
2022-03-24 13:23:42 +00:00
|
|
|
lu_byte numparams;
|
2022-01-24 02:23:08 +00:00
|
|
|
lu_byte is_vararg;
|
2022-03-24 13:23:42 +00:00
|
|
|
lu_byte maxstacksize;
|
|
|
|
int sizeupvalues;
|
|
|
|
int sizek;
|
2022-01-24 02:23:08 +00:00
|
|
|
int sizecode;
|
|
|
|
int sizelineinfo;
|
2022-03-24 13:23:42 +00:00
|
|
|
int sizep;
|
2022-01-24 02:23:08 +00:00
|
|
|
int sizelocvars;
|
2022-03-24 13:23:42 +00:00
|
|
|
int sizeabslineinfo;
|
|
|
|
int linedefined;
|
|
|
|
int lastlinedefined;
|
|
|
|
TValue *k;
|
|
|
|
Instruction *code;
|
|
|
|
struct Proto **p;
|
|
|
|
Upvaldesc *upvalues;
|
|
|
|
ls_byte *lineinfo;
|
|
|
|
AbsLineInfo *abslineinfo;
|
|
|
|
LocVar *locvars;
|
|
|
|
TString *source;
|
2022-01-24 02:23:08 +00:00
|
|
|
GCObject *gclist;
|
|
|
|
} Proto;
|
2022-03-24 13:23:42 +00:00
|
|
|
# 573 "./lua/lobject.h"
|
|
|
|
#define LUA_VUPVAL makevariant(LUA_TUPVAL, 0)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define LUA_VLCL makevariant(LUA_TFUNCTION, 0)
|
|
|
|
#define LUA_VLCF makevariant(LUA_TFUNCTION, 1)
|
|
|
|
#define LUA_VCCL makevariant(LUA_TFUNCTION, 2)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttisfunction(o) checktype(o, LUA_TFUNCTION)
|
|
|
|
#define ttisLclosure(o) checktag((o), ctb(LUA_VLCL))
|
|
|
|
#define ttislcf(o) checktag((o), LUA_VLCF)
|
|
|
|
#define ttisCclosure(o) checktag((o), ctb(LUA_VCCL))
|
|
|
|
#define ttisclosure(o) (ttisLclosure(o) || ttisCclosure(o))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define isLfunction(o) ttisLclosure(o)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc))
|
|
|
|
#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc))
|
|
|
|
#define fvalue(o) check_exp(ttislcf(o), val_(o).f)
|
|
|
|
#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define fvalueraw(v) ((v).f)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define setclLvalue(L,obj,x) \
|
|
|
|
{ TValue *io = (obj); LClosure *x_ = (x); \
|
|
|
|
val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VLCL)); \
|
|
|
|
checkliveness(L,io); }
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define setfvalue(obj,x) \
|
|
|
|
{ TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_VLCF); }
|
|
|
|
|
|
|
|
#define setclCvalue(L,obj,x) \
|
|
|
|
{ TValue *io = (obj); CClosure *x_ = (x); \
|
|
|
|
val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VCCL)); \
|
|
|
|
checkliveness(L,io); }
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef struct UpVal {
|
|
|
|
CommonHeader;
|
2022-03-24 13:23:42 +00:00
|
|
|
lu_byte tbc;
|
|
|
|
TValue *v;
|
2022-01-24 02:23:08 +00:00
|
|
|
union {
|
2022-03-24 13:23:42 +00:00
|
|
|
struct {
|
|
|
|
struct UpVal *next;
|
2022-01-24 02:23:08 +00:00
|
|
|
struct UpVal **previous;
|
|
|
|
} open;
|
2022-03-24 13:23:42 +00:00
|
|
|
TValue value;
|
2022-01-24 02:23:08 +00:00
|
|
|
} u;
|
|
|
|
} UpVal;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ClosureHeader \
|
2022-03-24 13:23:42 +00:00
|
|
|
CommonHeader; lu_byte nupvalues; GCObject *gclist
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
typedef struct CClosure {
|
|
|
|
ClosureHeader;
|
|
|
|
lua_CFunction f;
|
2022-03-24 13:23:42 +00:00
|
|
|
TValue upvalue[1];
|
2022-01-24 02:23:08 +00:00
|
|
|
} CClosure;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct LClosure {
|
|
|
|
ClosureHeader;
|
|
|
|
struct Proto *p;
|
2022-03-24 13:23:42 +00:00
|
|
|
UpVal *upvals[1];
|
2022-01-24 02:23:08 +00:00
|
|
|
} LClosure;
|
|
|
|
|
|
|
|
|
|
|
|
typedef union Closure {
|
|
|
|
CClosure c;
|
|
|
|
LClosure l;
|
|
|
|
} Closure;
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define getproto(o) (clLvalue(o)->p)
|
|
|
|
# 665 "./lua/lobject.h"
|
|
|
|
#define LUA_VTABLE makevariant(LUA_TTABLE, 0)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define ttistable(o) checktag((o), ctb(LUA_VTABLE))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
#define sethvalue(L,obj,x) \
|
|
|
|
{ TValue *io = (obj); Table *x_ = (x); \
|
|
|
|
val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTABLE)); \
|
|
|
|
checkliveness(L,io); }
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h)
|
|
|
|
# 686 "./lua/lobject.h"
|
2022-01-24 02:23:08 +00:00
|
|
|
typedef union Node {
|
|
|
|
struct NodeKey {
|
2022-03-24 13:23:42 +00:00
|
|
|
TValuefields;
|
|
|
|
lu_byte key_tt;
|
|
|
|
int next;
|
|
|
|
Value key_val;
|
2022-01-24 02:23:08 +00:00
|
|
|
} u;
|
2022-03-24 13:23:42 +00:00
|
|
|
TValue i_val;
|
2022-01-24 02:23:08 +00:00
|
|
|
} Node;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setnodekey(L,node,obj) \
|
|
|
|
{ Node *n_=(node); const TValue *io_=(obj); \
|
|
|
|
n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \
|
|
|
|
checkliveness(L,io_); }
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define getnodekey(L,obj,node) \
|
|
|
|
{ TValue *io_=(obj); const Node *n_=(node); \
|
|
|
|
io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \
|
|
|
|
checkliveness(L,io_); }
|
|
|
|
# 718 "./lua/lobject.h"
|
|
|
|
#define BITRAS (1 << 7)
|
|
|
|
#define isrealasize(t) (!((t)->flags & BITRAS))
|
|
|
|
#define setrealasize(t) ((t)->flags &= cast_byte(~BITRAS))
|
|
|
|
#define setnorealasize(t) ((t)->flags |= BITRAS)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct Table {
|
|
|
|
CommonHeader;
|
2022-03-24 13:23:42 +00:00
|
|
|
lu_byte flags;
|
|
|
|
lu_byte lsizenode;
|
|
|
|
unsigned int alimit;
|
|
|
|
TValue *array;
|
2022-01-24 02:23:08 +00:00
|
|
|
Node *node;
|
2022-03-24 13:23:42 +00:00
|
|
|
Node *lastfree;
|
2022-01-24 02:23:08 +00:00
|
|
|
struct Table *metatable;
|
|
|
|
GCObject *gclist;
|
|
|
|
} Table;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define keytt(node) ((node)->u.key_tt)
|
|
|
|
#define keyval(node) ((node)->u.key_val)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define keyisnil(node) (keytt(node) == LUA_TNIL)
|
|
|
|
#define keyisinteger(node) (keytt(node) == LUA_VNUMINT)
|
|
|
|
#define keyival(node) (keyval(node).i)
|
|
|
|
#define keyisshrstr(node) (keytt(node) == ctb(LUA_VSHRSTR))
|
|
|
|
#define keystrval(node) (gco2ts(keyval(node).gc))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define setnilkey(node) (keytt(node) = LUA_TNIL)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define gckey(n) (keyval(n).gc)
|
|
|
|
#define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL)
|
|
|
|
# 763 "./lua/lobject.h"
|
|
|
|
#define setdeadkey(node) (keytt(node) = LUA_TDEADKEY)
|
|
|
|
#define keyisdead(node) (keytt(node) == LUA_TDEADKEY)
|
|
|
|
# 773 "./lua/lobject.h"
|
2022-01-24 02:23:08 +00:00
|
|
|
#define lmod(s,size) \
|
2022-03-24 13:23:42 +00:00
|
|
|
(check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1)))))
|
|
|
|
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define twoto(x) (1<<(x))
|
|
|
|
#define sizenode(t) (twoto((t)->lsizenode))
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-24 13:23:42 +00:00
|
|
|
#define UTF8BUFFSZ 8
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x);
|
|
|
|
LUAI_FUNC int luaO_ceillog2 (unsigned int x);
|
|
|
|
LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1,
|
|
|
|
const TValue *p2, TValue *res);
|
|
|
|
LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1,
|
|
|
|
const TValue *p2, StkId res);
|
|
|
|
LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o);
|
|
|
|
LUAI_FUNC int luaO_hexavalue (int c);
|
|
|
|
LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj);
|
|
|
|
LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
|
|
|
|
va_list argp);
|
|
|
|
LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
|
|
|
|
LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|