diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-08-27 18:01:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-08-27 18:01:44 -0300 |
commit | 8332d5c8a5059b85da1adaa3f0197d0f57afae81 (patch) | |
tree | 8a2f59ff0803da3afbc7e8a409911c920d624e94 /lundump.c | |
parent | 885961be1d8e3f703b54d1d19e6c63617cd2ed24 (diff) | |
download | lua-8332d5c8a5059b85da1adaa3f0197d0f57afae81.tar.gz lua-8332d5c8a5059b85da1adaa3f0197d0f57afae81.tar.bz2 lua-8332d5c8a5059b85da1adaa3f0197d0f57afae81.zip |
parser fully reentrant(!)
Diffstat (limited to 'lundump.c')
-rw-r--r-- | lundump.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 1.62 2003/08/15 13:48:53 roberto Exp roberto $ | 2 | ** $Id: lundump.c,v 1.63 2003/08/25 19:51:54 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 | */ |
@@ -9,6 +9,7 @@ | |||
9 | #include "lua.h" | 9 | #include "lua.h" |
10 | 10 | ||
11 | #include "ldebug.h" | 11 | #include "ldebug.h" |
12 | #include "ldo.h" | ||
12 | #include "lfunc.h" | 13 | #include "lfunc.h" |
13 | #include "lmem.h" | 14 | #include "lmem.h" |
14 | #include "lopcodes.h" | 15 | #include "lopcodes.h" |
@@ -122,6 +123,7 @@ static void LoadLocals (LoadState* S, Proto* f) | |||
122 | n=LoadInt(S); | 123 | n=LoadInt(S); |
123 | f->locvars=luaM_newvector(S->L,n,LocVar); | 124 | f->locvars=luaM_newvector(S->L,n,LocVar); |
124 | f->sizelocvars=n; | 125 | f->sizelocvars=n; |
126 | for (i=0; i<n; i++) f->locvars[i].varname=NULL; | ||
125 | for (i=0; i<n; i++) | 127 | for (i=0; i<n; i++) |
126 | { | 128 | { |
127 | f->locvars[i].varname=LoadString(S); | 129 | f->locvars[i].varname=LoadString(S); |
@@ -147,6 +149,7 @@ static void LoadUpvalues (LoadState* S, Proto* f) | |||
147 | S->name,n,f->nups); | 149 | S->name,n,f->nups); |
148 | f->upvalues=luaM_newvector(S->L,n,TString*); | 150 | f->upvalues=luaM_newvector(S->L,n,TString*); |
149 | f->sizeupvalues=n; | 151 | f->sizeupvalues=n; |
152 | for (i=0; i<n; i++) f->upvalues[i]=NULL; | ||
150 | for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); | 153 | for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); |
151 | } | 154 | } |
152 | 155 | ||
@@ -158,6 +161,7 @@ static void LoadConstants (LoadState* S, Proto* f) | |||
158 | n=LoadInt(S); | 161 | n=LoadInt(S); |
159 | f->k=luaM_newvector(S->L,n,TObject); | 162 | f->k=luaM_newvector(S->L,n,TObject); |
160 | f->sizek=n; | 163 | f->sizek=n; |
164 | for (i=0; i<n; i++) setnilvalue(&f->k[i]); | ||
161 | for (i=0; i<n; i++) | 165 | for (i=0; i<n; i++) |
162 | { | 166 | { |
163 | TObject* o=&f->k[i]; | 167 | TObject* o=&f->k[i]; |
@@ -181,12 +185,15 @@ static void LoadConstants (LoadState* S, Proto* f) | |||
181 | n=LoadInt(S); | 185 | n=LoadInt(S); |
182 | f->p=luaM_newvector(S->L,n,Proto*); | 186 | f->p=luaM_newvector(S->L,n,Proto*); |
183 | f->sizep=n; | 187 | f->sizep=n; |
188 | for (i=0; i<n; i++) f->p[i]=NULL; | ||
184 | for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source); | 189 | for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source); |
185 | } | 190 | } |
186 | 191 | ||
187 | static Proto* LoadFunction (LoadState* S, TString* p) | 192 | static Proto* LoadFunction (LoadState* S, TString* p) |
188 | { | 193 | { |
189 | Proto* f=luaF_newproto(S->L); | 194 | Proto* f=luaF_newproto(S->L); |
195 | setptvalue2s(S->L->top, f); | ||
196 | incr_top(S->L); | ||
190 | f->source=LoadString(S); if (f->source==NULL) f->source=p; | 197 | f->source=LoadString(S); if (f->source==NULL) f->source=p; |
191 | f->lineDefined=LoadInt(S); | 198 | f->lineDefined=LoadInt(S); |
192 | f->nups=LoadByte(S); | 199 | f->nups=LoadByte(S); |
@@ -201,6 +208,7 @@ static Proto* LoadFunction (LoadState* S, TString* p) | |||
201 | #ifndef TRUST_BINARIES | 208 | #ifndef TRUST_BINARIES |
202 | if (!luaG_checkcode(f)) luaG_runerror(S->L,"bad code in %s",S->name); | 209 | if (!luaG_checkcode(f)) luaG_runerror(S->L,"bad code in %s",S->name); |
203 | #endif | 210 | #endif |
211 | S->L->top--; | ||
204 | return f; | 212 | return f; |
205 | } | 213 | } |
206 | 214 | ||