diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-27 15:56:15 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-27 15:56:15 -0300 |
commit | de84b3fecb9eb96f2d65bb754851dba8d815bb6d (patch) | |
tree | bf4ea360594645eb4b9f7beb2417ed1081d10276 /lundump.c | |
parent | 054179c2ffb108eb0c6535bed6288f70217c96ab (diff) | |
download | lua-de84b3fecb9eb96f2d65bb754851dba8d815bb6d.tar.gz lua-de84b3fecb9eb96f2d65bb754851dba8d815bb6d.tar.bz2 lua-de84b3fecb9eb96f2d65bb754851dba8d815bb6d.zip |
store number of upvalues of main function in front of the dump,
so that undump can create initial closure before reading its prototype
Diffstat (limited to 'lundump.c')
-rw-r--r-- | lundump.c | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 2.25 2014/02/13 12:11:34 roberto Exp roberto $ | 2 | ** $Id: lundump.c,v 2.26 2014/02/27 16:56:20 roberto Exp roberto $ |
3 | ** load precompiled Lua chunks | 3 | ** load precompiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -238,17 +238,11 @@ Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) | |||
238 | S.Z=Z; | 238 | S.Z=Z; |
239 | S.b=buff; | 239 | S.b=buff; |
240 | checkHeader(&S); | 240 | checkHeader(&S); |
241 | cl=luaF_newLclosure(L,1); | 241 | cl=luaF_newLclosure(L,LoadByte(&S)); |
242 | setclLvalue(L,L->top,cl); incr_top(L); | 242 | setclLvalue(L,L->top,cl); incr_top(L); |
243 | cl->l.p=luaF_newproto(L); | 243 | cl->l.p=luaF_newproto(L); |
244 | LoadFunction(&S,cl->l.p); | 244 | LoadFunction(&S,cl->l.p); |
245 | if (cl->l.p->sizeupvalues != 1) | 245 | lua_assert(cl->l.nupvalues==cl->l.p->sizeupvalues); |
246 | { | ||
247 | Proto* p=cl->l.p; | ||
248 | cl=luaF_newLclosure(L,cl->l.p->sizeupvalues); | ||
249 | cl->l.p=p; | ||
250 | setclLvalue(L,L->top-1,cl); | ||
251 | } | ||
252 | luai_verifycode(L,buff,cl->l.p); | 246 | luai_verifycode(L,buff,cl->l.p); |
253 | return cl; | 247 | return cl; |
254 | } | 248 | } |