no more checks for non-default compilation options + luaU_dump has
new option to strip debug info
This commit is contained in:
8
lapi.c
8
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
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** 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);
|
lua_lock(L);
|
||||||
api_checknelems(L, 1);
|
api_checknelems(L, 1);
|
||||||
o = L->top - 1;
|
o = L->top - 1;
|
||||||
if (isLfunction(o) && clvalue(o)->l.nupvalues == 0) {
|
if (isLfunction(o) && clvalue(o)->l.nupvalues == 0)
|
||||||
luaU_dump(L, clvalue(o)->l.p, writer, data);
|
status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
|
||||||
status = 1;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
status = 0;
|
status = 0;
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
|
|||||||
18
ldump.c
18
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
|
** save bytecodes
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -22,6 +22,7 @@ typedef struct {
|
|||||||
lua_State* L;
|
lua_State* L;
|
||||||
lua_Chunkwriter write;
|
lua_Chunkwriter write;
|
||||||
void* data;
|
void* data;
|
||||||
|
int strip;
|
||||||
} DumpState;
|
} DumpState;
|
||||||
|
|
||||||
static void DumpBlock(const void* b, size_t size, DumpState* D)
|
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->numparams,D);
|
||||||
DumpByte(f->is_vararg,D);
|
DumpByte(f->is_vararg,D);
|
||||||
DumpByte(f->maxstacksize,D);
|
DumpByte(f->maxstacksize,D);
|
||||||
DumpLines(f,D);
|
if (D->strip) DumpInt(0,D); else DumpLines(f,D);
|
||||||
DumpLocals(f,D);
|
if (D->strip) DumpInt(0,D); else DumpLocals(f,D);
|
||||||
DumpUpvalues(f,D);
|
if (D->strip) DumpInt(0,D); else DumpUpvalues(f,D);
|
||||||
DumpConstants(f,D);
|
DumpConstants(f,D);
|
||||||
DumpCode(f,D);
|
DumpCode(f,D);
|
||||||
}
|
}
|
||||||
@@ -147,10 +148,6 @@ static void DumpHeader(DumpState* D)
|
|||||||
DumpByte(sizeof(int),D);
|
DumpByte(sizeof(int),D);
|
||||||
DumpByte(sizeof(size_t),D);
|
DumpByte(sizeof(size_t),D);
|
||||||
DumpByte(sizeof(Instruction),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);
|
DumpByte(sizeof(lua_Number),D);
|
||||||
DumpNumber(TEST_NUMBER,D);
|
DumpNumber(TEST_NUMBER,D);
|
||||||
}
|
}
|
||||||
@@ -158,13 +155,14 @@ static void DumpHeader(DumpState* D)
|
|||||||
/*
|
/*
|
||||||
** dump function as precompiled chunk
|
** 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;
|
DumpState D;
|
||||||
D.L=L;
|
D.L=L;
|
||||||
D.write=w;
|
D.write=w;
|
||||||
D.data=data;
|
D.data=data;
|
||||||
|
D.strip=strip;
|
||||||
DumpHeader(&D);
|
DumpHeader(&D);
|
||||||
DumpFunction(Main,NULL,&D);
|
DumpFunction(Main,NULL,&D);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
** load pre-compiled Lua chunks
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -241,10 +241,6 @@ static void LoadHeader (LoadState* S)
|
|||||||
TESTSIZE(sizeof(int),"int");
|
TESTSIZE(sizeof(int),"int");
|
||||||
TESTSIZE(sizeof(size_t), "size_t");
|
TESTSIZE(sizeof(size_t), "size_t");
|
||||||
TESTSIZE(sizeof(Instruction), "Instruction");
|
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");
|
TESTSIZE(sizeof(lua_Number), "number");
|
||||||
x=LoadNumber(S);
|
x=LoadNumber(S);
|
||||||
if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */
|
if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */
|
||||||
|
|||||||
@@ -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
|
** load pre-compiled Lua chunks
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +17,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff);
|
|||||||
int luaU_endianness (void);
|
int luaU_endianness (void);
|
||||||
|
|
||||||
/* dump one chunk; from ldump.c */
|
/* 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 */
|
/* print one chunk; from print.c */
|
||||||
void luaU_print (const Proto* Main);
|
void luaU_print (const Proto* Main);
|
||||||
|
|||||||
Reference in New Issue
Block a user