diff --git a/ldump.c b/ldump.c index 6864a3fa..b7606d29 100644 --- a/ldump.c +++ b/ldump.c @@ -1,5 +1,5 @@ /* -** $Id: ldump.c,v 2.17 2012/01/23 23:02:10 roberto Exp roberto $ +** $Id: ldump.c,v 2.18 2013/04/12 19:07:09 roberto Exp roberto $ ** save precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -52,6 +52,11 @@ static void DumpNumber(lua_Number x, DumpState* D) DumpVar(x,D); } +static void DumpInteger(lua_Integer x, DumpState* D) +{ + DumpVar(x,D); +} + static void DumpVector(const void* b, int n, size_t size, DumpState* D) { DumpInt(n,D); @@ -84,18 +89,21 @@ static void DumpConstants(const Proto* f, DumpState* D) for (i=0; ik[i]; - DumpChar(ttnov(o),D); - switch (ttnov(o)) + DumpChar(ttype(o),D); + switch (ttype(o)) { case LUA_TNIL: break; case LUA_TBOOLEAN: DumpChar(bvalue(o),D); break; - case LUA_TNUMBER: - DumpNumber(nvalue(o),D); + case LUA_TNUMFLT: + DumpNumber(fltvalue(o),D); + break; + case LUA_TNUMINT: + DumpInteger(ivalue(o),D); break; - case LUA_TSTRING: + case LUA_TSHRSTR: case LUA_TLNGSTR: DumpString(rawtsvalue(o),D); break; default: lua_assert(0); diff --git a/lundump.c b/lundump.c index 2bd8e197..0a8db845 100644 --- a/lundump.c +++ b/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.21 2012/03/19 22:58:09 roberto Exp roberto $ +** $Id: lundump.c,v 2.22 2012/05/08 13:53:33 roberto Exp roberto $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -69,6 +69,13 @@ static lua_Number LoadNumber(LoadState* S) return x; } +static lua_Integer LoadInteger(LoadState* S) +{ + lua_Integer x; + LoadVar(S,x); + return x; +} + static TString* LoadString(LoadState* S) { size_t size; @@ -112,10 +119,13 @@ static void LoadConstants(LoadState* S, Proto* f) case LUA_TBOOLEAN: setbvalue(o,LoadChar(S)); break; - case LUA_TNUMBER: + case LUA_TNUMFLT: setnvalue(o,LoadNumber(S)); break; - case LUA_TSTRING: + case LUA_TNUMINT: + setivalue(o,LoadInteger(S)); + break; + case LUA_TSHRSTR: case LUA_TLNGSTR: setsvalue2n(S->L,o,LoadString(S)); break; default: lua_assert(0);