commit 433cb1d13a767023e03111fc09c46903f40366ff
parent d66198719d10e393dfba57c1f4aeea307cdb49ea
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 15 Aug 2003 10:48:31 -0300
no more checks for non-default compilation options + luaU_dump has
new option to strip debug info
Diffstat:
4 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 1.239 2003/05/14 21:06:56 roberto Exp roberto $
+** $Id: lapi.c,v 1.240 2003/07/07 13:34:25 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -732,10 +732,8 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) {
lua_lock(L);
api_checknelems(L, 1);
o = L->top - 1;
- if (isLfunction(o) && clvalue(o)->l.nupvalues == 0) {
- luaU_dump(L, clvalue(o)->l.p, writer, data);
- status = 1;
- }
+ if (isLfunction(o) && clvalue(o)->l.nupvalues == 0)
+ status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
else
status = 0;
lua_unlock(L);
diff --git a/ldump.c b/ldump.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldump.c,v 1.4 2003/02/11 23:52:12 lhf Exp $
+** $Id: ldump.c,v 1.4 2003/02/11 23:52:12 lhf Exp lhf $
** save bytecodes
** See Copyright Notice in lua.h
*/
@@ -22,6 +22,7 @@ typedef struct {
lua_State* L;
lua_Chunkwriter write;
void* data;
+ int strip;
} DumpState;
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)
DumpByte(f->numparams,D);
DumpByte(f->is_vararg,D);
DumpByte(f->maxstacksize,D);
- DumpLines(f,D);
- DumpLocals(f,D);
- DumpUpvalues(f,D);
+ if (D->strip) DumpInt(0,D); else DumpLines(f,D);
+ if (D->strip) DumpInt(0,D); else DumpLocals(f,D);
+ if (D->strip) DumpInt(0,D); else DumpUpvalues(f,D);
DumpConstants(f,D);
DumpCode(f,D);
}
@@ -147,10 +148,6 @@ static void DumpHeader(DumpState* D)
DumpByte(sizeof(int),D);
DumpByte(sizeof(size_t),D);
DumpByte(sizeof(Instruction),D);
- DumpByte(SIZE_OP,D);
- DumpByte(SIZE_A,D);
- DumpByte(SIZE_B,D);
- DumpByte(SIZE_C,D);
DumpByte(sizeof(lua_Number),D);
DumpNumber(TEST_NUMBER,D);
}
@@ -158,13 +155,14 @@ static void DumpHeader(DumpState* D)
/*
** dump function as precompiled chunk
*/
-void luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data)
+int luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data, int strip)
{
DumpState D;
D.L=L;
D.write=w;
D.data=data;
+ D.strip=strip;
DumpHeader(&D);
DumpFunction(Main,NULL,&D);
+ return 1;
}
-
diff --git a/lundump.c b/lundump.c
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 1.49 2003/04/07 20:34:20 lhf Exp $
+** $Id: lundump.c,v 1.49 2003/04/07 20:34:20 lhf Exp lhf $
** load pre-compiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -241,10 +241,6 @@ static void LoadHeader (LoadState* S)
TESTSIZE(sizeof(int),"int");
TESTSIZE(sizeof(size_t), "size_t");
TESTSIZE(sizeof(Instruction), "Instruction");
- TESTSIZE(SIZE_OP, "OP");
- TESTSIZE(SIZE_A, "A");
- TESTSIZE(SIZE_B, "B");
- TESTSIZE(SIZE_C, "C");
TESTSIZE(sizeof(lua_Number), "number");
x=LoadNumber(S);
if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */
diff --git a/lundump.h b/lundump.h
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.h,v 1.31 2003/04/10 17:39:41 roberto Exp roberto $
+** $Id: lundump.h,v 1.30 2003/04/07 20:34:20 lhf Exp lhf $
** load pre-compiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -17,7 +17,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff);
int luaU_endianness (void);
/* dump one chunk; from ldump.c */
-void luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data);
+int luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data, int strip);
/* print one chunk; from print.c */
void luaU_print (const Proto* Main);