diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-28 13:13:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-28 13:13:01 -0300 |
commit | 99a1c06ea34c823e7692deac3a23fec4831d8f79 (patch) | |
tree | 23e8781389ab725ce07529377fe61a6eb88c4004 /ldump.c | |
parent | 93e28031de81efacb7f84b142f57d5c2cdf4744e (diff) | |
download | lua-99a1c06ea34c823e7692deac3a23fec4831d8f79.tar.gz lua-99a1c06ea34c823e7692deac3a23fec4831d8f79.tar.bz2 lua-99a1c06ea34c823e7692deac3a23fec4831d8f79.zip |
more regularity with vectors + sizeof computed by the macros themselves
Diffstat (limited to 'ldump.c')
-rw-r--r-- | ldump.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldump.c,v 2.21 2014/02/27 18:56:15 roberto Exp roberto $ | 2 | ** $Id: ldump.c,v 2.22 2014/02/28 12:25:12 roberto Exp roberto $ |
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 | */ |
@@ -23,8 +23,9 @@ typedef struct { | |||
23 | int status; | 23 | int status; |
24 | } DumpState; | 24 | } DumpState; |
25 | 25 | ||
26 | #define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) | 26 | |
27 | #define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) | 27 | #define DumpVar(x,D) DumpBlock(&x,sizeof(x),D) |
28 | #define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D) | ||
28 | 29 | ||
29 | static void DumpBlock(const void* b, size_t size, DumpState* D) | 30 | static void DumpBlock(const void* b, size_t size, DumpState* D) |
30 | { | 31 | { |
@@ -57,12 +58,6 @@ static void DumpInteger(lua_Integer x, DumpState* D) | |||
57 | DumpVar(x,D); | 58 | DumpVar(x,D); |
58 | } | 59 | } |
59 | 60 | ||
60 | static void DumpVector(const void* b, int n, size_t size, DumpState* D) | ||
61 | { | ||
62 | DumpInt(n,D); | ||
63 | DumpMem(b,n,size,D); | ||
64 | } | ||
65 | |||
66 | static void DumpString(const TString* s, DumpState* D) | 61 | static void DumpString(const TString* s, DumpState* D) |
67 | { | 62 | { |
68 | if (s==NULL) | 63 | if (s==NULL) |
@@ -78,7 +73,11 @@ static void DumpString(const TString* s, DumpState* D) | |||
78 | } | 73 | } |
79 | } | 74 | } |
80 | 75 | ||
81 | #define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) | 76 | static void DumpCode(const Proto* f, DumpState* D) |
77 | { | ||
78 | DumpInt(f->sizecode,D); | ||
79 | DumpVector(f->code,f->sizecode,D); | ||
80 | } | ||
82 | 81 | ||
83 | static void DumpFunction(const Proto* f, DumpState* D); | 82 | static void DumpFunction(const Proto* f, DumpState* D); |
84 | 83 | ||
@@ -130,7 +129,8 @@ static void DumpDebug(const Proto* f, DumpState* D) | |||
130 | int i,n; | 129 | int i,n; |
131 | DumpString((D->strip) ? NULL : f->source,D); | 130 | DumpString((D->strip) ? NULL : f->source,D); |
132 | n= (D->strip) ? 0 : f->sizelineinfo; | 131 | n= (D->strip) ? 0 : f->sizelineinfo; |
133 | DumpVector(f->lineinfo,n,sizeof(int),D); | 132 | DumpInt(n,D); |
133 | DumpVector(f->lineinfo,n,D); | ||
134 | n= (D->strip) ? 0 : f->sizelocvars; | 134 | n= (D->strip) ? 0 : f->sizelocvars; |
135 | DumpInt(n,D); | 135 | DumpInt(n,D); |
136 | for (i=0; i<n; i++) | 136 | for (i=0; i<n; i++) |