forked from len0rd/rockbox
Revert "Update lua plugin to 5.2.3"
FILE typedef to *void needs more work to not break sim and application builds. I checked only a few random native builds unfortunately. Sorry for inconvenience.
This commit is contained in:
parent
36378988ad
commit
bfd0179042
64 changed files with 5733 additions and 9088 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ldump.c,v 2.17.1.1 2013/04/12 18:48:47 roberto Exp $
|
||||
** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
|
||||
** save precompiled Lua chunks
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ typedef struct {
|
|||
} DumpState;
|
||||
|
||||
#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
|
||||
#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
|
||||
#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
|
||||
|
||||
static void DumpBlock(const void* b, size_t size, DumpState* D)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ static void DumpVector(const void* b, int n, size_t size, DumpState* D)
|
|||
|
||||
static void DumpString(const TString* s, DumpState* D)
|
||||
{
|
||||
if (s==NULL)
|
||||
if (s==NULL || getstr(s)==NULL)
|
||||
{
|
||||
size_t size=0;
|
||||
DumpVar(size,D);
|
||||
|
@ -69,13 +69,13 @@ static void DumpString(const TString* s, DumpState* D)
|
|||
{
|
||||
size_t size=s->tsv.len+1; /* include trailing '\0' */
|
||||
DumpVar(size,D);
|
||||
DumpBlock(getstr(s),size*sizeof(char),D);
|
||||
DumpBlock(getstr(s),size,D);
|
||||
}
|
||||
}
|
||||
|
||||
#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
|
||||
|
||||
static void DumpFunction(const Proto* f, DumpState* D);
|
||||
static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
|
||||
|
||||
static void DumpConstants(const Proto* f, DumpState* D)
|
||||
{
|
||||
|
@ -84,8 +84,8 @@ static void DumpConstants(const Proto* f, DumpState* D)
|
|||
for (i=0; i<n; i++)
|
||||
{
|
||||
const TValue* o=&f->k[i];
|
||||
DumpChar(ttypenv(o),D);
|
||||
switch (ttypenv(o))
|
||||
DumpChar(ttype(o),D);
|
||||
switch (ttype(o))
|
||||
{
|
||||
case LUA_TNIL:
|
||||
break;
|
||||
|
@ -98,29 +98,19 @@ static void DumpConstants(const Proto* f, DumpState* D)
|
|||
case LUA_TSTRING:
|
||||
DumpString(rawtsvalue(o),D);
|
||||
break;
|
||||
default: lua_assert(0);
|
||||
default:
|
||||
lua_assert(0); /* cannot happen */
|
||||
break;
|
||||
}
|
||||
}
|
||||
n=f->sizep;
|
||||
DumpInt(n,D);
|
||||
for (i=0; i<n; i++) DumpFunction(f->p[i],D);
|
||||
}
|
||||
|
||||
static void DumpUpvalues(const Proto* f, DumpState* D)
|
||||
{
|
||||
int i,n=f->sizeupvalues;
|
||||
DumpInt(n,D);
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
DumpChar(f->upvalues[i].instack,D);
|
||||
DumpChar(f->upvalues[i].idx,D);
|
||||
}
|
||||
for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
|
||||
}
|
||||
|
||||
static void DumpDebug(const Proto* f, DumpState* D)
|
||||
{
|
||||
int i,n;
|
||||
DumpString((D->strip) ? NULL : f->source,D);
|
||||
n= (D->strip) ? 0 : f->sizelineinfo;
|
||||
DumpVector(f->lineinfo,n,sizeof(int),D);
|
||||
n= (D->strip) ? 0 : f->sizelocvars;
|
||||
|
@ -133,25 +123,26 @@ static void DumpDebug(const Proto* f, DumpState* D)
|
|||
}
|
||||
n= (D->strip) ? 0 : f->sizeupvalues;
|
||||
DumpInt(n,D);
|
||||
for (i=0; i<n; i++) DumpString(f->upvalues[i].name,D);
|
||||
for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
|
||||
}
|
||||
|
||||
static void DumpFunction(const Proto* f, DumpState* D)
|
||||
static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
|
||||
{
|
||||
DumpString((f->source==p || D->strip) ? NULL : f->source,D);
|
||||
DumpInt(f->linedefined,D);
|
||||
DumpInt(f->lastlinedefined,D);
|
||||
DumpChar(f->nups,D);
|
||||
DumpChar(f->numparams,D);
|
||||
DumpChar(f->is_vararg,D);
|
||||
DumpChar(f->maxstacksize,D);
|
||||
DumpCode(f,D);
|
||||
DumpConstants(f,D);
|
||||
DumpUpvalues(f,D);
|
||||
DumpDebug(f,D);
|
||||
}
|
||||
|
||||
static void DumpHeader(DumpState* D)
|
||||
{
|
||||
lu_byte h[LUAC_HEADERSIZE];
|
||||
char h[LUAC_HEADERSIZE];
|
||||
luaU_header(h);
|
||||
DumpBlock(h,LUAC_HEADERSIZE,D);
|
||||
}
|
||||
|
@ -168,6 +159,6 @@ int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip
|
|||
D.strip=strip;
|
||||
D.status=0;
|
||||
DumpHeader(&D);
|
||||
DumpFunction(f,&D);
|
||||
DumpFunction(f,NULL,&D);
|
||||
return D.status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue