aboutsummaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-27 15:56:15 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-27 15:56:15 -0300
commitde84b3fecb9eb96f2d65bb754851dba8d815bb6d (patch)
treebf4ea360594645eb4b9f7beb2417ed1081d10276 /lundump.c
parent054179c2ffb108eb0c6535bed6288f70217c96ab (diff)
downloadlua-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.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/lundump.c b/lundump.c
index 25e98dd6..a976e6dd 100644
--- a/lundump.c
+++ b/lundump.c
@@ -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}