Clearer distinction between types and tags
LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
This commit is contained in:
24
lvm.c
24
lvm.c
@@ -577,14 +577,14 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
|
||||
}
|
||||
/* values have same type and same variant */
|
||||
switch (ttypetag(t1)) {
|
||||
case LUA_TNIL: case LUA_TFALSE: case LUA_TTRUE: return 1;
|
||||
case LUA_TNUMINT: return (ivalue(t1) == ivalue(t2));
|
||||
case LUA_TNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2));
|
||||
case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
|
||||
case LUA_TLCF: return fvalue(t1) == fvalue(t2);
|
||||
case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2));
|
||||
case LUA_TLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2));
|
||||
case LUA_TUSERDATA: {
|
||||
case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE: return 1;
|
||||
case LUA_VNUMINT: return (ivalue(t1) == ivalue(t2));
|
||||
case LUA_VNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2));
|
||||
case LUA_VLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
|
||||
case LUA_VLCF: return fvalue(t1) == fvalue(t2);
|
||||
case LUA_VSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2));
|
||||
case LUA_VLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2));
|
||||
case LUA_VUSERDATA: {
|
||||
if (uvalue(t1) == uvalue(t2)) return 1;
|
||||
else if (L == NULL) return 0;
|
||||
tm = fasttm(L, uvalue(t1)->metatable, TM_EQ);
|
||||
@@ -592,7 +592,7 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
|
||||
tm = fasttm(L, uvalue(t2)->metatable, TM_EQ);
|
||||
break; /* will try TM */
|
||||
}
|
||||
case LUA_TTABLE: {
|
||||
case LUA_VTABLE: {
|
||||
if (hvalue(t1) == hvalue(t2)) return 1;
|
||||
else if (L == NULL) return 0;
|
||||
tm = fasttm(L, hvalue(t1)->metatable, TM_EQ);
|
||||
@@ -680,18 +680,18 @@ void luaV_concat (lua_State *L, int total) {
|
||||
void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
|
||||
const TValue *tm;
|
||||
switch (ttypetag(rb)) {
|
||||
case LUA_TTABLE: {
|
||||
case LUA_VTABLE: {
|
||||
Table *h = hvalue(rb);
|
||||
tm = fasttm(L, h->metatable, TM_LEN);
|
||||
if (tm) break; /* metamethod? break switch to call it */
|
||||
setivalue(s2v(ra), luaH_getn(h)); /* else primitive len */
|
||||
return;
|
||||
}
|
||||
case LUA_TSHRSTR: {
|
||||
case LUA_VSHRSTR: {
|
||||
setivalue(s2v(ra), tsvalue(rb)->shrlen);
|
||||
return;
|
||||
}
|
||||
case LUA_TLNGSTR: {
|
||||
case LUA_VLNGSTR: {
|
||||
setivalue(s2v(ra), tsvalue(rb)->u.lnglen);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user