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:
Roberto Ierusalimschy
2020-01-31 11:09:53 -03:00
parent 69c7139ff8
commit 46c3587a6f
22 changed files with 231 additions and 213 deletions

18
ldump.c
View File

@@ -111,21 +111,21 @@ static void DumpConstants (const Proto *f, DumpState *D) {
DumpInt(n, D);
for (i = 0; i < n; i++) {
const TValue *o = &f->k[i];
DumpByte(ttypetag(o), D);
switch (ttypetag(o)) {
case LUA_TNIL: case LUA_TFALSE: case LUA_TTRUE:
break;
case LUA_TNUMFLT:
int tt = ttypetag(o);
DumpByte(tt, D);
switch (tt) {
case LUA_VNUMFLT:
DumpNumber(fltvalue(o), D);
break;
case LUA_TNUMINT:
case LUA_VNUMINT:
DumpInteger(ivalue(o), D);
break;
case LUA_TSHRSTR:
case LUA_TLNGSTR:
case LUA_VSHRSTR:
case LUA_VLNGSTR:
DumpString(tsvalue(o), D);
break;
default: lua_assert(0);
default:
lua_assert(tt == LUA_VNIL || tt == LUA_VFALSE || tt == LUA_VTRUE);
}
}
}