summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldump.c20
-rw-r--r--lundump.c16
2 files changed, 27 insertions, 9 deletions
diff --git a/ldump.c b/ldump.c
index 6864a3fa..b7606d29 100644
--- a/ldump.c
+++ b/ldump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldump.c,v 2.17 2012/01/23 23:02:10 roberto Exp roberto $ 2** $Id: ldump.c,v 2.18 2013/04/12 19:07:09 roberto Exp roberto $
3** save precompiled Lua chunks 3** save precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -52,6 +52,11 @@ static void DumpNumber(lua_Number x, DumpState* D)
52 DumpVar(x,D); 52 DumpVar(x,D);
53} 53}
54 54
55static void DumpInteger(lua_Integer x, DumpState* D)
56{
57 DumpVar(x,D);
58}
59
55static void DumpVector(const void* b, int n, size_t size, DumpState* D) 60static void DumpVector(const void* b, int n, size_t size, DumpState* D)
56{ 61{
57 DumpInt(n,D); 62 DumpInt(n,D);
@@ -84,18 +89,21 @@ static void DumpConstants(const Proto* f, DumpState* D)
84 for (i=0; i<n; i++) 89 for (i=0; i<n; i++)
85 { 90 {
86 const TValue* o=&f->k[i]; 91 const TValue* o=&f->k[i];
87 DumpChar(ttnov(o),D); 92 DumpChar(ttype(o),D);
88 switch (ttnov(o)) 93 switch (ttype(o))
89 { 94 {
90 case LUA_TNIL: 95 case LUA_TNIL:
91 break; 96 break;
92 case LUA_TBOOLEAN: 97 case LUA_TBOOLEAN:
93 DumpChar(bvalue(o),D); 98 DumpChar(bvalue(o),D);
94 break; 99 break;
95 case LUA_TNUMBER: 100 case LUA_TNUMFLT:
96 DumpNumber(nvalue(o),D); 101 DumpNumber(fltvalue(o),D);
102 break;
103 case LUA_TNUMINT:
104 DumpInteger(ivalue(o),D);
97 break; 105 break;
98 case LUA_TSTRING: 106 case LUA_TSHRSTR: case LUA_TLNGSTR:
99 DumpString(rawtsvalue(o),D); 107 DumpString(rawtsvalue(o),D);
100 break; 108 break;
101 default: lua_assert(0); 109 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 @@
1/* 1/*
2** $Id: lundump.c,v 2.21 2012/03/19 22:58:09 roberto Exp roberto $ 2** $Id: lundump.c,v 2.22 2012/05/08 13:53:33 roberto Exp roberto $
3** load precompiled Lua chunks 3** load precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -69,6 +69,13 @@ static lua_Number LoadNumber(LoadState* S)
69 return x; 69 return x;
70} 70}
71 71
72static lua_Integer LoadInteger(LoadState* S)
73{
74 lua_Integer x;
75 LoadVar(S,x);
76 return x;
77}
78
72static TString* LoadString(LoadState* S) 79static TString* LoadString(LoadState* S)
73{ 80{
74 size_t size; 81 size_t size;
@@ -112,10 +119,13 @@ static void LoadConstants(LoadState* S, Proto* f)
112 case LUA_TBOOLEAN: 119 case LUA_TBOOLEAN:
113 setbvalue(o,LoadChar(S)); 120 setbvalue(o,LoadChar(S));
114 break; 121 break;
115 case LUA_TNUMBER: 122 case LUA_TNUMFLT:
116 setnvalue(o,LoadNumber(S)); 123 setnvalue(o,LoadNumber(S));
117 break; 124 break;
118 case LUA_TSTRING: 125 case LUA_TNUMINT:
126 setivalue(o,LoadInteger(S));
127 break;
128 case LUA_TSHRSTR: case LUA_TLNGSTR:
119 setsvalue2n(S->L,o,LoadString(S)); 129 setsvalue2n(S->L,o,LoadString(S));
120 break; 130 break;
121 default: lua_assert(0); 131 default: lua_assert(0);