Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/compiler/lcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ int FuncState::addk(Proto *proto, TValue *v) {
int FuncState::k2proto(TValue *key, TValue *v) {
TValue val;
Proto *proto = getProto();
int tag = luaH_get(getKCache(), key, &val); /* query scanner table */
LuaT tag = luaH_get(getKCache(), key, &val); /* query scanner table */
if (!tagisempty(tag)) { /* is there an index there? */
int k = cast_int(ivalue(&val));
/* collisions can happen only for float keys */
Expand Down Expand Up @@ -466,22 +466,22 @@ void FuncState::floatCode(int reg, lua_Number flt) {
*/
static void const2exp (TValue *v, expdesc *e) {
switch (ttypetag(v)) {
case LUA_VNUMINT:
case LuaT::NUMINT:
e->setKind(VKINT); e->setIntValue(ivalue(v));
break;
case LUA_VNUMFLT:
case LuaT::NUMFLT:
e->setKind(VKFLT); e->setFloatValue(fltvalue(v));
break;
case LUA_VFALSE:
case LuaT::VFALSE:
e->setKind(VFALSE);
break;
case LUA_VTRUE:
case LuaT::VTRUE:
e->setKind(VTRUE);
break;
case LUA_VNIL:
case LuaT::NIL:
e->setKind(VNIL);
break;
case LUA_VSHRSTR: case LUA_VLNGSTR:
case LuaT::SHRSTR: case LuaT::LNGSTR:
e->setKind(VKSTR); e->setStringValue(tsvalue(v));
break;
default: lua_assert(0);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/llex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ l_noret LexState::syntaxError(const char *msg) {
TString* LexState::anchorStr(TString *ts) {
lua_State *luaState = getLuaState();
TValue oldts;
int tag = luaH_getstr(getTable(), ts, &oldts);
LuaT tag = luaH_getstr(getTable(), ts, &oldts);
if (!tagisempty(tag)) /* string already present? */
return tsvalue(&oldts); /* use stored value */
else { /* create a new entry */
Expand Down
36 changes: 18 additions & 18 deletions src/core/lapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) {
const TValue *o = L->getStackSubsystem().indexToValue(L,idx);
switch (ttypetag(o)) {
case LUA_VSHRSTR: return static_cast<lua_Unsigned>(tsvalue(o)->length());
case LUA_VLNGSTR: return static_cast<lua_Unsigned>(tsvalue(o)->length());
case LUA_VUSERDATA: return static_cast<lua_Unsigned>(uvalue(o)->getLen());
case LUA_VTABLE: {
case LuaT::SHRSTR: return static_cast<lua_Unsigned>(tsvalue(o)->length());
case LuaT::LNGSTR: return static_cast<lua_Unsigned>(tsvalue(o)->length());
case LuaT::USERDATA: return static_cast<lua_Unsigned>(uvalue(o)->getLen());
case LuaT::TABLE: {
lua_Unsigned res;
lua_lock(L);
res = luaH_getn(L, hvalue(o));
Expand Down Expand Up @@ -438,8 +438,8 @@ LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
LUA_API const void *lua_topointer (lua_State *L, int idx) {
const TValue *o = L->getStackSubsystem().indexToValue(L,idx);
switch (ttypetag(o)) {
case LUA_VLCF: return cast_voidp(cast_sizet(fvalue(o)));
case LUA_VUSERDATA: case LUA_VLIGHTUSERDATA:
case LuaT::LCF: return cast_voidp(cast_sizet(fvalue(o)));
case LuaT::USERDATA: case LuaT::LIGHTUSERDATA:
return touserdata(o);
default: {
if (iscollectable(o))
Expand Down Expand Up @@ -612,7 +612,7 @@ LUA_API int lua_pushthread (lua_State *L) {


static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
lu_byte tag;
LuaT tag;
TString *str = TString::create(L, k);
tag = luaV_fastget(t, str, s2v(L->getTop().p), luaH_getstr);
if (!tagisempty(tag))
Expand All @@ -634,7 +634,7 @@ static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
*/
static void getGlobalTable (lua_State *L, TValue *gt) {
Table *registry = hvalue(G(L)->getRegistry());
lu_byte tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt);
LuaT tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt);
(void)tag; /* avoid not-used warnings when checks are off */
api_check(L, novariant(tag) == LUA_TTABLE, "global table must exist");
}
Expand All @@ -652,7 +652,7 @@ LUA_API int lua_gettable (lua_State *L, int idx) {
lua_lock(L);
api_checkpop(L, 1);
TValue *t = L->getStackSubsystem().indexToValue(L,idx);
lu_byte tag = luaV_fastget(t, s2v(L->getTop().p - 1), s2v(L->getTop().p - 1), luaH_get);
LuaT tag = luaV_fastget(t, s2v(L->getTop().p - 1), s2v(L->getTop().p - 1), luaH_get);
if (tagisempty(tag))
tag = luaV_finishget(L, t, s2v(L->getTop().p - 1), L->getTop().p - 1, tag);
lua_unlock(L);
Expand All @@ -669,7 +669,7 @@ LUA_API int lua_getfield (lua_State *L, int idx, const char *k) {
LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
lua_lock(L);
TValue *t = L->getStackSubsystem().indexToValue(L,idx);
lu_byte tag;
LuaT tag;
luaV_fastgeti(t, n, s2v(L->getTop().p), tag);
if (tagisempty(tag)) {
TValue key;
Expand All @@ -682,7 +682,7 @@ LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
}


static int finishrawget (lua_State *L, lu_byte tag) {
static int finishrawget (lua_State *L, LuaT tag) {
if (tagisempty(tag)) /* avoid copying empty items to the stack */
setnilvalue(s2v(L->getTop().p));
api_incr_top(L);
Expand All @@ -702,7 +702,7 @@ LUA_API int lua_rawget (lua_State *L, int idx) {
lua_lock(L);
api_checkpop(L, 1);
Table *t = gettable(L, idx);
lu_byte tag = luaH_get(t, s2v(L->getTop().p - 1), s2v(L->getTop().p - 1));
LuaT tag = luaH_get(t, s2v(L->getTop().p - 1), s2v(L->getTop().p - 1));
L->getStackSubsystem().pop(); /* pop key */
return finishrawget(L, tag);
}
Expand All @@ -711,7 +711,7 @@ LUA_API int lua_rawget (lua_State *L, int idx) {
LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) {
lua_lock(L);
Table *t = gettable(L, idx);
lu_byte tag;
LuaT tag;
luaH_fastgeti(t, n, s2v(L->getTop().p), tag);
return finishrawget(L, tag);
}
Expand Down Expand Up @@ -1290,15 +1290,15 @@ LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) {
static const char *aux_upvalue (TValue *fi, int n, TValue **val,
GCObject **owner) {
switch (ttypetag(fi)) {
case LUA_VCCL: { /* C closure */
case LuaT::CCL: { /* C closure */
CClosure *f = clCvalue(fi);
if (!(cast_uint(n) - 1u < cast_uint(f->getNumUpvalues())))
return nullptr; /* 'n' not in [1, f->getNumUpvalues()] */
*val = f->getUpvalue(n-1);
if (owner) *owner = obj2gco(f);
return "";
}
case LUA_VLCL: { /* Lua closure */
case LuaT::LCL: { /* Lua closure */
LClosure *f = clLvalue(fi);
TString *name;
Proto *p = f->getProto();
Expand Down Expand Up @@ -1364,16 +1364,16 @@ static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) {
LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
TValue *fi = L->getStackSubsystem().indexToValue(L,fidx);
switch (ttypetag(fi)) {
case LUA_VLCL: { /* lua closure */
case LuaT::LCL: { /* lua closure */
return *getupvalref(L, fidx, n, nullptr);
}
case LUA_VCCL: { /* C closure */
case LuaT::CCL: { /* C closure */
CClosure *f = clCvalue(fi);
if (1 <= n && n <= f->getNumUpvalues())
return f->getUpvalue(n - 1);
/* else */
} /* FALLTHROUGH */
case LUA_VLCF:
case LuaT::LCF:
return nullptr; /* light C functions have no upvalues */
default: {
api_check(L, 0, "function expected");
Expand Down
2 changes: 1 addition & 1 deletion src/core/ldebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


/* Both CClosure and LClosure have tt at same offset (from GCBase) */
#define LuaClosure(f) ((f) != nullptr && (f)->c.getType() == LUA_VLCL)
#define LuaClosure(f) ((f) != nullptr && (f)->c.getType() == ctb(LuaT::LCL))

static const char strlocal[] = "local";
static const char strupval[] = "upvalue";
Expand Down
12 changes: 6 additions & 6 deletions src/core/ldo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,11 @@ int lua_State::preTailCall(CallInfo *ci_arg, StkId func,
unsigned status_val = LUA_MULTRET + 1;
retry:
switch (ttypetag(s2v(func))) {
case LUA_VCCL: /* C closure */
case LuaT::CCL: /* C closure */
return preCallC(func, status_val, clCvalue(s2v(func))->getFunction());
case LUA_VLCF: /* light C function */
case LuaT::LCF: /* light C function */
return preCallC(func, status_val, fvalue(s2v(func)));
case LUA_VLCL: { /* Lua function */
case LuaT::LCL: { /* Lua function */
Proto *p = clLvalue(s2v(func))->getProto();
int fsize = p->getMaxStackSize(); /* frame size */
int nfixparams = p->getNumParams();
Expand Down Expand Up @@ -628,13 +628,13 @@ CallInfo* lua_State::preCall(StkId func, int nresults) {
lua_assert(status_val <= MAXRESULTS + 1);
retry:
switch (ttypetag(s2v(func))) {
case LUA_VCCL: /* C closure */
case LuaT::CCL: /* C closure */
preCallC(func, status_val, clCvalue(s2v(func))->getFunction());
return nullptr;
case LUA_VLCF: /* light C function */
case LuaT::LCF: /* light C function */
preCallC(func, status_val, fvalue(s2v(func)));
return nullptr;
case LUA_VLCL: { /* Lua function */
case LuaT::LCL: { /* Lua function */
CallInfo *ci_new;
Proto *p = clLvalue(s2v(func))->getProto();
int narg = cast_int(getTop().p - func) - 1; /* number of real arguments */
Expand Down
4 changes: 2 additions & 2 deletions src/core/lstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) {
lua_lock(L);
luaC_checkGC(L);
/* create new thread */
o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), lxOffset());
o = luaC_newobjdt(L, ctb(LuaT::THREAD), sizeof(LX), lxOffset());
L1 = gco2th(o);
/* anchor it on L stack */
setthvalue2s(L, L->getTop().p, L1);
Expand Down Expand Up @@ -335,7 +335,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned seed) {
(*f)(ud, nullptr, LUA_TTHREAD, sizeof(global_State)));
if (g == nullptr) return nullptr;
L = &g->getMainThread()->l;
L->setType(LUA_VTHREAD);
L->setType(ctb(LuaT::THREAD));
g->setCurrentWhite(bitmask(WHITE0BIT));
L->setMarked(g->getWhite());
preinit_thread(L, g);
Expand Down
16 changes: 8 additions & 8 deletions src/core/lstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ struct lua_State : public GCBase<lua_State> {
void finishOp();
void concat(int total);
void objlen(StkId ra, const TValue *rb);
lu_byte finishGet(const TValue *t, TValue *key, StkId val, lu_byte tag);
LuaT finishGet(const TValue *t, TValue *key, StkId val, LuaT tag);
void finishSet(const TValue *t, TValue *key, TValue *val, int aux);

// Arithmetic operation methods (formerly luaV_* functions, implemented in lvm.cpp)
Expand Down Expand Up @@ -1229,17 +1229,17 @@ inline TString* gco2ts(GCObject* o) noexcept {
}

inline Udata* gco2u(GCObject* o) noexcept {
lua_assert(o->getType() == LUA_VUSERDATA);
lua_assert(o->getType() == ctb(LuaT::USERDATA));
return reinterpret_cast<Udata*>(o);
}

inline LClosure* gco2lcl(GCObject* o) noexcept {
lua_assert(o->getType() == LUA_VLCL);
lua_assert(o->getType() == ctb(LuaT::LCL));
return reinterpret_cast<LClosure*>(o);
}

inline CClosure* gco2ccl(GCObject* o) noexcept {
lua_assert(o->getType() == LUA_VCCL);
lua_assert(o->getType() == ctb(LuaT::CCL));
return reinterpret_cast<CClosure*>(o);
}

Expand All @@ -1249,22 +1249,22 @@ inline Closure* gco2cl(GCObject* o) noexcept {
}

inline Table* gco2t(GCObject* o) noexcept {
lua_assert(o->getType() == LUA_VTABLE);
lua_assert(o->getType() == ctb(LuaT::TABLE));
return reinterpret_cast<Table*>(o);
}

inline Proto* gco2p(GCObject* o) noexcept {
lua_assert(o->getType() == LUA_VPROTO);
lua_assert(o->getType() == ctb(LuaT::PROTO));
return reinterpret_cast<Proto*>(o);
}

inline lua_State* gco2th(GCObject* o) noexcept {
lua_assert(o->getType() == LUA_VTHREAD);
lua_assert(o->getType() == ctb(LuaT::THREAD));
return reinterpret_cast<lua_State*>(o);
}

inline UpVal* gco2upv(GCObject* o) noexcept {
lua_assert(o->getType() == LUA_VUPVAL);
lua_assert(o->getType() == ctb(LuaT::UPVAL));
return reinterpret_cast<UpVal*>(o);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/ltm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
}


lu_byte luaT_callTMres (lua_State *L, const TValue *f, const TValue *p1,
LuaT luaT_callTMres (lua_State *L, const TValue *f, const TValue *p1,
const TValue *p2, StkId res) {
ptrdiff_t result = L->saveStack(res);
StkId func = L->getTop().p;
Expand All @@ -144,7 +144,7 @@ static int callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
if (notm(tm))
return -1; /* tag method not found */
else /* call tag method and return the tag of the result */
return luaT_callTMres(L, tm, p1, p2, res);
return static_cast<int>(luaT_callTMres(L, tm, p1, p2, res));
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/ltm.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ LUAI_FUNC void luaT_init (lua_State *L);

LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
const TValue *p2, const TValue *p3);
LUAI_FUNC lu_byte luaT_callTMres (lua_State *L, const TValue *f,
LUAI_FUNC LuaT luaT_callTMres (lua_State *L, const TValue *f,
const TValue *p1, const TValue *p2, StkId p3);
LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
StkId res, TMS event);
Expand Down
Loading
Loading