diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-11 08:46:24 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-11 08:46:24 -0200 |
commit | 7a40cdbda0a171da223094208dd3c6e3eca13922 (patch) | |
tree | c95840411ac26e11b0683d4a5fc88402c1d0a70a /lundump.c | |
parent | 3cdeacbbfba9308dd2dcc995a9bcc510bfcead31 (diff) | |
download | lua-7a40cdbda0a171da223094208dd3c6e3eca13922.tar.gz lua-7a40cdbda0a171da223094208dd3c6e3eca13922.tar.bz2 lua-7a40cdbda0a171da223094208dd3c6e3eca13922.zip |
different variables for number of upvalues and size of upvalue array
(makes code clearer)
Diffstat (limited to 'lundump.c')
-rw-r--r-- | lundump.c | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 1.47 2003/01/10 11:08:45 lhf Exp $ | 2 | ** $Id: lundump.c,v 1.59 2003/01/27 15:52:57 roberto Exp roberto $ |
3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -140,21 +140,14 @@ static void LoadLines (LoadState* S, Proto* f) | |||
140 | 140 | ||
141 | static void LoadUpvalues (LoadState* S, Proto* f) | 141 | static void LoadUpvalues (LoadState* S, Proto* f) |
142 | { | 142 | { |
143 | int i,n,noname; | 143 | int i,n; |
144 | n=LoadInt(S); | 144 | n=LoadInt(S); |
145 | noname=(n==0); | 145 | if (n!=0 && n!=f->nups) |
146 | if (!noname && n!=f->nupvalues) | ||
147 | luaG_runerror(S->L,"bad nupvalues in %s: read %d; expected %d", | 146 | luaG_runerror(S->L,"bad nupvalues in %s: read %d; expected %d", |
148 | S->name,n,f->nupvalues); | 147 | S->name,n,f->nups); |
149 | n=f->nupvalues; | ||
150 | f->upvalues=luaM_newvector(S->L,n,TString*); | 148 | f->upvalues=luaM_newvector(S->L,n,TString*); |
151 | if (noname) | 149 | f->sizeupvalues = n; |
152 | { | 150 | for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); |
153 | TString* name=luaS_newliteral(S->L,"(no name)"); | ||
154 | for (i=0; i<n; i++) f->upvalues[i]=name; | ||
155 | } | ||
156 | else | ||
157 | for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); | ||
158 | } | 151 | } |
159 | 152 | ||
160 | static Proto* LoadFunction (LoadState* S, TString* p); | 153 | static Proto* LoadFunction (LoadState* S, TString* p); |
@@ -196,7 +189,7 @@ static Proto* LoadFunction (LoadState* S, TString* p) | |||
196 | Proto* f=luaF_newproto(S->L); | 189 | Proto* f=luaF_newproto(S->L); |
197 | f->source=LoadString(S); if (f->source==NULL) f->source=p; | 190 | f->source=LoadString(S); if (f->source==NULL) f->source=p; |
198 | f->lineDefined=LoadInt(S); | 191 | f->lineDefined=LoadInt(S); |
199 | f->nupvalues=LoadInt(S); | 192 | f->nups=LoadByte(S); |
200 | f->numparams=LoadByte(S); | 193 | f->numparams=LoadByte(S); |
201 | f->is_vararg=LoadByte(S); | 194 | f->is_vararg=LoadByte(S); |
202 | f->maxstacksize=LoadByte(S); | 195 | f->maxstacksize=LoadByte(S); |