diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-08-15 10:48:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-08-15 10:48:53 -0300 |
commit | 433cb1d13a767023e03111fc09c46903f40366ff (patch) | |
tree | df5d105368debb523ea838c3e0c06e60c94ae9ca | |
parent | d66198719d10e393dfba57c1f4aeea307cdb49ea (diff) | |
download | lua-433cb1d13a767023e03111fc09c46903f40366ff.tar.gz lua-433cb1d13a767023e03111fc09c46903f40366ff.tar.bz2 lua-433cb1d13a767023e03111fc09c46903f40366ff.zip |
no more checks for non-default compilation options + luaU_dump has
new option to strip debug info
-rw-r--r-- | lapi.c | 8 | ||||
-rw-r--r-- | ldump.c | 18 | ||||
-rw-r--r-- | lundump.c | 6 | ||||
-rw-r--r-- | lundump.h | 4 |
4 files changed, 14 insertions, 22 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.239 2003/05/14 21:06:56 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.240 2003/07/07 13:34:25 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -732,10 +732,8 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { | |||
732 | lua_lock(L); | 732 | lua_lock(L); |
733 | api_checknelems(L, 1); | 733 | api_checknelems(L, 1); |
734 | o = L->top - 1; | 734 | o = L->top - 1; |
735 | if (isLfunction(o) && clvalue(o)->l.nupvalues == 0) { | 735 | if (isLfunction(o) && clvalue(o)->l.nupvalues == 0) |
736 | luaU_dump(L, clvalue(o)->l.p, writer, data); | 736 | status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); |
737 | status = 1; | ||
738 | } | ||
739 | else | 737 | else |
740 | status = 0; | 738 | status = 0; |
741 | lua_unlock(L); | 739 | lua_unlock(L); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldump.c,v 1.4 2003/02/11 23:52:12 lhf Exp $ | 2 | ** $Id: ldump.c,v 1.4 2003/02/11 23:52:12 lhf Exp lhf $ |
3 | ** save bytecodes | 3 | ** save bytecodes |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -22,6 +22,7 @@ typedef struct { | |||
22 | lua_State* L; | 22 | lua_State* L; |
23 | lua_Chunkwriter write; | 23 | lua_Chunkwriter write; |
24 | void* data; | 24 | void* data; |
25 | int strip; | ||
25 | } DumpState; | 26 | } DumpState; |
26 | 27 | ||
27 | static void DumpBlock(const void* b, size_t size, DumpState* D) | 28 | static void DumpBlock(const void* b, size_t size, DumpState* D) |
@@ -132,9 +133,9 @@ static void DumpFunction(const Proto* f, const TString* p, DumpState* D) | |||
132 | DumpByte(f->numparams,D); | 133 | DumpByte(f->numparams,D); |
133 | DumpByte(f->is_vararg,D); | 134 | DumpByte(f->is_vararg,D); |
134 | DumpByte(f->maxstacksize,D); | 135 | DumpByte(f->maxstacksize,D); |
135 | DumpLines(f,D); | 136 | if (D->strip) DumpInt(0,D); else DumpLines(f,D); |
136 | DumpLocals(f,D); | 137 | if (D->strip) DumpInt(0,D); else DumpLocals(f,D); |
137 | DumpUpvalues(f,D); | 138 | if (D->strip) DumpInt(0,D); else DumpUpvalues(f,D); |
138 | DumpConstants(f,D); | 139 | DumpConstants(f,D); |
139 | DumpCode(f,D); | 140 | DumpCode(f,D); |
140 | } | 141 | } |
@@ -147,10 +148,6 @@ static void DumpHeader(DumpState* D) | |||
147 | DumpByte(sizeof(int),D); | 148 | DumpByte(sizeof(int),D); |
148 | DumpByte(sizeof(size_t),D); | 149 | DumpByte(sizeof(size_t),D); |
149 | DumpByte(sizeof(Instruction),D); | 150 | DumpByte(sizeof(Instruction),D); |
150 | DumpByte(SIZE_OP,D); | ||
151 | DumpByte(SIZE_A,D); | ||
152 | DumpByte(SIZE_B,D); | ||
153 | DumpByte(SIZE_C,D); | ||
154 | DumpByte(sizeof(lua_Number),D); | 151 | DumpByte(sizeof(lua_Number),D); |
155 | DumpNumber(TEST_NUMBER,D); | 152 | DumpNumber(TEST_NUMBER,D); |
156 | } | 153 | } |
@@ -158,13 +155,14 @@ static void DumpHeader(DumpState* D) | |||
158 | /* | 155 | /* |
159 | ** dump function as precompiled chunk | 156 | ** dump function as precompiled chunk |
160 | */ | 157 | */ |
161 | void luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data) | 158 | int luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data, int strip) |
162 | { | 159 | { |
163 | DumpState D; | 160 | DumpState D; |
164 | D.L=L; | 161 | D.L=L; |
165 | D.write=w; | 162 | D.write=w; |
166 | D.data=data; | 163 | D.data=data; |
164 | D.strip=strip; | ||
167 | DumpHeader(&D); | 165 | DumpHeader(&D); |
168 | DumpFunction(Main,NULL,&D); | 166 | DumpFunction(Main,NULL,&D); |
167 | return 1; | ||
169 | } | 168 | } |
170 | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 1.49 2003/04/07 20:34:20 lhf Exp $ | 2 | ** $Id: lundump.c,v 1.49 2003/04/07 20:34:20 lhf Exp lhf $ |
3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -241,10 +241,6 @@ static void LoadHeader (LoadState* S) | |||
241 | TESTSIZE(sizeof(int),"int"); | 241 | TESTSIZE(sizeof(int),"int"); |
242 | TESTSIZE(sizeof(size_t), "size_t"); | 242 | TESTSIZE(sizeof(size_t), "size_t"); |
243 | TESTSIZE(sizeof(Instruction), "Instruction"); | 243 | TESTSIZE(sizeof(Instruction), "Instruction"); |
244 | TESTSIZE(SIZE_OP, "OP"); | ||
245 | TESTSIZE(SIZE_A, "A"); | ||
246 | TESTSIZE(SIZE_B, "B"); | ||
247 | TESTSIZE(SIZE_C, "C"); | ||
248 | TESTSIZE(sizeof(lua_Number), "number"); | 244 | TESTSIZE(sizeof(lua_Number), "number"); |
249 | x=LoadNumber(S); | 245 | x=LoadNumber(S); |
250 | if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */ | 246 | if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.h,v 1.31 2003/04/10 17:39:41 roberto Exp roberto $ | 2 | ** $Id: lundump.h,v 1.30 2003/04/07 20:34:20 lhf Exp lhf $ |
3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -17,7 +17,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff); | |||
17 | int luaU_endianness (void); | 17 | int luaU_endianness (void); |
18 | 18 | ||
19 | /* dump one chunk; from ldump.c */ | 19 | /* dump one chunk; from ldump.c */ |
20 | void luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data); | 20 | int luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data, int strip); |
21 | 21 | ||
22 | /* print one chunk; from print.c */ | 22 | /* print one chunk; from print.c */ |
23 | void luaU_print (const Proto* Main); | 23 | void luaU_print (const Proto* Main); |