aboutsummaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
Diffstat (limited to 'lundump.c')
-rw-r--r--lundump.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/lundump.c b/lundump.c
index 0777dc0f..10508ed4 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.63 2003/08/25 19:51:54 roberto Exp roberto $ 2** $Id: lundump.c,v 1.64 2003/08/27 21:01:44 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*/
@@ -158,13 +158,14 @@ static Proto* LoadFunction (LoadState* S, TString* p);
158static void LoadConstants (LoadState* S, Proto* f) 158static void LoadConstants (LoadState* S, Proto* f)
159{ 159{
160 int i,n; 160 int i,n;
161 lua_State *L=S->L;
161 n=LoadInt(S); 162 n=LoadInt(S);
162 f->k=luaM_newvector(S->L,n,TObject); 163 f->k=luaM_newvector(L,n,TValue);
163 f->sizek=n; 164 f->sizek=n;
164 for (i=0; i<n; i++) setnilvalue(&f->k[i]); 165 for (i=0; i<n; i++) setnilvalue(&f->k[i]);
165 for (i=0; i<n; i++) 166 for (i=0; i<n; i++)
166 { 167 {
167 TObject* o=&f->k[i]; 168 TValue* o=&f->k[i];
168 int t=LoadByte(S); 169 int t=LoadByte(S);
169 switch (t) 170 switch (t)
170 { 171 {
@@ -172,18 +173,18 @@ static void LoadConstants (LoadState* S, Proto* f)
172 setnvalue(o,LoadNumber(S)); 173 setnvalue(o,LoadNumber(S));
173 break; 174 break;
174 case LUA_TSTRING: 175 case LUA_TSTRING:
175 setsvalue2n(o,LoadString(S)); 176 setsvalue2n(L, o,LoadString(S));
176 break; 177 break;
177 case LUA_TNIL: 178 case LUA_TNIL:
178 setnilvalue(o); 179 setnilvalue(o);
179 break; 180 break;
180 default: 181 default:
181 luaG_runerror(S->L,"bad constant type (%d) in %s",t,S->name); 182 luaG_runerror(L,"bad constant type (%d) in %s",t,S->name);
182 break; 183 break;
183 } 184 }
184 } 185 }
185 n=LoadInt(S); 186 n=LoadInt(S);
186 f->p=luaM_newvector(S->L,n,Proto*); 187 f->p=luaM_newvector(L,n,Proto*);
187 f->sizep=n; 188 f->sizep=n;
188 for (i=0; i<n; i++) f->p[i]=NULL; 189 for (i=0; i<n; i++) f->p[i]=NULL;
189 for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source); 190 for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
@@ -191,9 +192,10 @@ static void LoadConstants (LoadState* S, Proto* f)
191 192
192static Proto* LoadFunction (LoadState* S, TString* p) 193static Proto* LoadFunction (LoadState* S, TString* p)
193{ 194{
194 Proto* f=luaF_newproto(S->L); 195 lua_State *L=S->L;
195 setptvalue2s(S->L->top, f); 196 Proto* f=luaF_newproto(L);
196 incr_top(S->L); 197 setptvalue2s(L, L->top, f);
198 incr_top(L);
197 f->source=LoadString(S); if (f->source==NULL) f->source=p; 199 f->source=LoadString(S); if (f->source==NULL) f->source=p;
198 f->lineDefined=LoadInt(S); 200 f->lineDefined=LoadInt(S);
199 f->nups=LoadByte(S); 201 f->nups=LoadByte(S);
@@ -206,9 +208,9 @@ static Proto* LoadFunction (LoadState* S, TString* p)
206 LoadConstants(S,f); 208 LoadConstants(S,f);
207 LoadCode(S,f); 209 LoadCode(S,f);
208#ifndef TRUST_BINARIES 210#ifndef TRUST_BINARIES
209 if (!luaG_checkcode(f)) luaG_runerror(S->L,"bad code in %s",S->name); 211 if (!luaG_checkcode(f)) luaG_runerror(L,"bad code in %s",S->name);
210#endif 212#endif
211 S->L->top--; 213 L->top--;
212 return f; 214 return f;
213} 215}
214 216