diff options
author | Lua Team <team@lua.org> | 2010-01-08 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2010-01-08 12:00:00 +0000 |
commit | 22912c77c80f8de8f7accd3319c726f7c5349fd3 (patch) | |
tree | caf064ecca31cd2ef1c919c585ee6b3d5e6d25d6 /src/lundump.c | |
parent | 300cd56eb905be061aa75bb665549b3b85109bbe (diff) | |
download | lua-github-5.2.0-work1.tar.gz |
Lua 5.2.0-work15.2.0-work1
Diffstat (limited to 'src/lundump.c')
-rw-r--r-- | src/lundump.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/lundump.c b/src/lundump.c index 8010a457..244d6e52 100644 --- a/src/lundump.c +++ b/src/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** $Id: lundump.c,v 2.12 2009/09/30 15:38:37 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -29,7 +29,6 @@ typedef struct { #ifdef LUAC_TRUST_BINARIES #define IF(c,s) -#define error(S,s) #else #define IF(c,s) if (c) error(S,s) @@ -111,10 +110,10 @@ static void LoadConstants(LoadState* S, Proto* f) switch (t) { case LUA_TNIL: - setnilvalue(o); + setnilvalue(o); break; case LUA_TBOOLEAN: - setbvalue(o,LoadChar(S)!=0); + setbvalue(o,LoadChar(S)!=0); break; case LUA_TNUMBER: setnvalue(o,LoadNumber(S)); @@ -123,7 +122,7 @@ static void LoadConstants(LoadState* S, Proto* f) setsvalue2n(S->L,o,LoadString(S)); break; default: - error(S,"bad constant"); + IF (1, "bad constant"); break; } } @@ -134,6 +133,20 @@ static void LoadConstants(LoadState* S, Proto* f) for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source); } +static void LoadUpvalues(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,Upvaldesc); + f->sizeupvalues=n; + for (i=0; i<n; i++) f->upvalues[i].name=NULL; + for (i=0; i<n; i++) + { + f->upvalues[i].instack=LoadChar(S); + f->upvalues[i].idx=LoadChar(S); + } +} + static void LoadDebug(LoadState* S, Proto* f) { int i,n; @@ -152,31 +165,28 @@ static void LoadDebug(LoadState* S, Proto* f) f->locvars[i].endpc=LoadInt(S); } n=LoadInt(S); - f->upvalues=luaM_newvector(S->L,n,TString*); - f->sizeupvalues=n; - for (i=0; i<n; i++) f->upvalues[i]=NULL; - for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); + for (i=0; i<n; i++) f->upvalues[i].name=LoadString(S); } static Proto* LoadFunction(LoadState* S, TString* p) { Proto* f; - if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + if (++G(S->L)->nCcalls > LUAI_MAXCCALLS) error(S, "function nest too deep"); f=luaF_newproto(S->L); setptvalue2s(S->L,S->L->top,f); incr_top(S->L); f->source=LoadString(S); if (f->source==NULL) f->source=p; f->linedefined=LoadInt(S); f->lastlinedefined=LoadInt(S); - f->nups=LoadByte(S); f->numparams=LoadByte(S); f->is_vararg=LoadByte(S); f->maxstacksize=LoadByte(S); + f->envreg=LoadByte(S); LoadCode(S,f); LoadConstants(S,f); + LoadUpvalues(S,f); LoadDebug(S,f); - IF (!luaG_checkcode(f), "bad code"); S->L->top--; - S->L->nCcalls--; + G(S->L)->nCcalls--; return f; } |