diff options
Diffstat (limited to 'ldump.c')
| -rw-r--r-- | ldump.c | 15 |
1 files changed, 6 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldump.c,v 2.12 2009/09/30 15:38:37 roberto Exp roberto $ | 2 | ** $Id: ldump.c,v 1.17 2010/10/13 21:04:52 lhf Exp $ |
| 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 | */ |
| @@ -75,7 +75,7 @@ static void DumpString(const TString* s, DumpState* D) | |||
| 75 | 75 | ||
| 76 | #define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) | 76 | #define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) |
| 77 | 77 | ||
| 78 | static void DumpFunction(const Proto* f, const TString* p, DumpState* D); | 78 | static void DumpFunction(const Proto* f, DumpState* D); |
| 79 | 79 | ||
| 80 | static void DumpConstants(const Proto* f, DumpState* D) | 80 | static void DumpConstants(const Proto* f, DumpState* D) |
| 81 | { | 81 | { |
| @@ -98,14 +98,11 @@ static void DumpConstants(const Proto* f, DumpState* D) | |||
| 98 | case LUA_TSTRING: | 98 | case LUA_TSTRING: |
| 99 | DumpString(rawtsvalue(o),D); | 99 | DumpString(rawtsvalue(o),D); |
| 100 | break; | 100 | break; |
| 101 | default: | ||
| 102 | lua_assert(0); /* cannot happen */ | ||
| 103 | break; | ||
| 104 | } | 101 | } |
| 105 | } | 102 | } |
| 106 | n=f->sizep; | 103 | n=f->sizep; |
| 107 | DumpInt(n,D); | 104 | DumpInt(n,D); |
| 108 | for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D); | 105 | for (i=0; i<n; i++) DumpFunction(f->p[i],D); |
| 109 | } | 106 | } |
| 110 | 107 | ||
| 111 | static void DumpUpvalues(const Proto* f, DumpState* D) | 108 | static void DumpUpvalues(const Proto* f, DumpState* D) |
| @@ -122,6 +119,7 @@ static void DumpUpvalues(const Proto* f, DumpState* D) | |||
| 122 | static void DumpDebug(const Proto* f, DumpState* D) | 119 | static void DumpDebug(const Proto* f, DumpState* D) |
| 123 | { | 120 | { |
| 124 | int i,n; | 121 | int i,n; |
| 122 | DumpString((D->strip) ? NULL : f->source,D); | ||
| 125 | n= (D->strip) ? 0 : f->sizelineinfo; | 123 | n= (D->strip) ? 0 : f->sizelineinfo; |
| 126 | DumpVector(f->lineinfo,n,sizeof(int),D); | 124 | DumpVector(f->lineinfo,n,sizeof(int),D); |
| 127 | n= (D->strip) ? 0 : f->sizelocvars; | 125 | n= (D->strip) ? 0 : f->sizelocvars; |
| @@ -137,9 +135,8 @@ static void DumpDebug(const Proto* f, DumpState* D) | |||
| 137 | for (i=0; i<n; i++) DumpString(f->upvalues[i].name,D); | 135 | for (i=0; i<n; i++) DumpString(f->upvalues[i].name,D); |
| 138 | } | 136 | } |
| 139 | 137 | ||
| 140 | static void DumpFunction(const Proto* f, const TString* p, DumpState* D) | 138 | static void DumpFunction(const Proto* f, DumpState* D) |
| 141 | { | 139 | { |
| 142 | DumpString((f->source==p || D->strip) ? NULL : f->source,D); | ||
| 143 | DumpInt(f->linedefined,D); | 140 | DumpInt(f->linedefined,D); |
| 144 | DumpInt(f->lastlinedefined,D); | 141 | DumpInt(f->lastlinedefined,D); |
| 145 | DumpChar(f->numparams,D); | 142 | DumpChar(f->numparams,D); |
| @@ -170,6 +167,6 @@ int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip | |||
| 170 | D.strip=strip; | 167 | D.strip=strip; |
| 171 | D.status=0; | 168 | D.status=0; |
| 172 | DumpHeader(&D); | 169 | DumpHeader(&D); |
| 173 | DumpFunction(f,NULL,&D); | 170 | DumpFunction(f,&D); |
| 174 | return D.status; | 171 | return D.status; |
| 175 | } | 172 | } |
