diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-28 13:32:50 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-28 13:32:50 -0300 |
commit | 5938212748636d21d6f4b372481ab3b6dd6c7538 (patch) | |
tree | fa5d0a28dac1ff6c087585bc684534eb1ae82298 /lundump.c | |
parent | 1829911d7c1c16cf01dfdbfc8e7a26cfa10ec797 (diff) | |
download | lua-5938212748636d21d6f4b372481ab3b6dd6c7538.tar.gz lua-5938212748636d21d6f4b372481ab3b6dd6c7538.tar.bz2 lua-5938212748636d21d6f4b372481ab3b6dd6c7538.zip |
information about upvalues (where they come from) kept in Proto structure,
instead of sequence of pseudo-opcodes after OP_CLOSURE
Diffstat (limited to 'lundump.c')
-rw-r--r-- | lundump.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 2.9 2008/04/07 18:44:23 roberto Exp roberto $ | 2 | ** $Id: lundump.c,v 2.10 2009/04/30 17:42:21 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 | */ |
@@ -133,6 +133,20 @@ static void LoadConstants(LoadState* S, Proto* f) | |||
133 | for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source); | 133 | for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void LoadUpvalues(LoadState* S, Proto* f) | ||
137 | { | ||
138 | int i,n; | ||
139 | n=LoadInt(S); | ||
140 | f->upvalues=luaM_newvector(S->L,n,Upvaldesc); | ||
141 | f->sizeupvalues=n; | ||
142 | for (i=0; i<n; i++) f->upvalues[i].name=NULL; | ||
143 | for (i=0; i<n; i++) | ||
144 | { | ||
145 | f->upvalues[i].instack=LoadChar(S); | ||
146 | f->upvalues[i].idx=LoadChar(S); | ||
147 | } | ||
148 | } | ||
149 | |||
136 | static void LoadDebug(LoadState* S, Proto* f) | 150 | static void LoadDebug(LoadState* S, Proto* f) |
137 | { | 151 | { |
138 | int i,n; | 152 | int i,n; |
@@ -151,10 +165,7 @@ static void LoadDebug(LoadState* S, Proto* f) | |||
151 | f->locvars[i].endpc=LoadInt(S); | 165 | f->locvars[i].endpc=LoadInt(S); |
152 | } | 166 | } |
153 | n=LoadInt(S); | 167 | n=LoadInt(S); |
154 | f->upvalues=luaM_newvector(S->L,n,TString*); | 168 | for (i=0; i<n; i++) f->upvalues[i].name=LoadString(S); |
155 | f->sizeupvalues=n; | ||
156 | for (i=0; i<n; i++) f->upvalues[i]=NULL; | ||
157 | for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); | ||
158 | } | 169 | } |
159 | 170 | ||
160 | static Proto* LoadFunction(LoadState* S, TString* p) | 171 | static Proto* LoadFunction(LoadState* S, TString* p) |
@@ -166,12 +177,12 @@ static Proto* LoadFunction(LoadState* S, TString* p) | |||
166 | f->source=LoadString(S); if (f->source==NULL) f->source=p; | 177 | f->source=LoadString(S); if (f->source==NULL) f->source=p; |
167 | f->linedefined=LoadInt(S); | 178 | f->linedefined=LoadInt(S); |
168 | f->lastlinedefined=LoadInt(S); | 179 | f->lastlinedefined=LoadInt(S); |
169 | f->nups=LoadByte(S); | ||
170 | f->numparams=LoadByte(S); | 180 | f->numparams=LoadByte(S); |
171 | f->is_vararg=LoadByte(S); | 181 | f->is_vararg=LoadByte(S); |
172 | f->maxstacksize=LoadByte(S); | 182 | f->maxstacksize=LoadByte(S); |
173 | LoadCode(S,f); | 183 | LoadCode(S,f); |
174 | LoadConstants(S,f); | 184 | LoadConstants(S,f); |
185 | LoadUpvalues(S,f); | ||
175 | LoadDebug(S,f); | 186 | LoadDebug(S,f); |
176 | S->L->top--; | 187 | S->L->top--; |
177 | G(S->L)->nCcalls--; | 188 | G(S->L)->nCcalls--; |