diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-25 11:57:18 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-25 11:57:18 -0200 |
commit | d11e5adf55b11a446671775a6c7803e066fc94e8 (patch) | |
tree | b7881e03e792bcc46f497577e8141b5ecc2e5b17 | |
parent | 99e340b2ba08226f4f7b457b170296af8d82959b (diff) | |
download | lua-d11e5adf55b11a446671775a6c7803e066fc94e8.tar.gz lua-d11e5adf55b11a446671775a6c7803e066fc94e8.tar.bz2 lua-d11e5adf55b11a446671775a6c7803e066fc94e8.zip |
`const' array in protos breaked in 3 arrays (for strings, numbers, and
prototypes).
-rw-r--r-- | ldebug.c | 5 | ||||
-rw-r--r-- | lfunc.c | 14 | ||||
-rw-r--r-- | lgc.c | 8 | ||||
-rw-r--r-- | lobject.h | 11 | ||||
-rw-r--r-- | lopcodes.h | 8 | ||||
-rw-r--r-- | lparser.c | 83 | ||||
-rw-r--r-- | lvm.c | 37 |
7 files changed, 86 insertions, 80 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.4 1999/12/30 18:28:40 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.5 2000/01/19 12:00:45 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -94,8 +94,7 @@ static const char *luaG_getname (lua_State *L, const char **name, StkId top) { | |||
94 | if (ttype(f) == LUA_T_LCLMARK) | 94 | if (ttype(f) == LUA_T_LCLMARK) |
95 | f = protovalue(f); | 95 | f = protovalue(f); |
96 | LUA_ASSERT(L, ttype(f) == LUA_T_LMARK, "must be a Lua function"); | 96 | LUA_ASSERT(L, ttype(f) == LUA_T_LMARK, "must be a Lua function"); |
97 | LUA_ASSERT(L, ttype(&tfvalue(f)->consts[i]) == LUA_T_STRING, ""); | 97 | *name = tfvalue(f)->strcnst[i]->str; |
98 | *name = tsvalue(&tfvalue(f)->consts[i])->str; | ||
99 | return luaO_typename(f+2); | 98 | return luaO_typename(f+2); |
100 | } | 99 | } |
101 | } | 100 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 1.15 1999/11/22 13:12:07 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 1.16 1999/12/27 17:33:22 roberto Exp roberto $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -34,8 +34,12 @@ TProtoFunc *luaF_newproto (lua_State *L) { | |||
34 | f->code = NULL; | 34 | f->code = NULL; |
35 | f->lineDefined = 0; | 35 | f->lineDefined = 0; |
36 | f->source = NULL; | 36 | f->source = NULL; |
37 | f->consts = NULL; | 37 | f->strcnst = NULL; |
38 | f->nconsts = 0; | 38 | f->nstrcnst = 0; |
39 | f->numcnst = NULL; | ||
40 | f->nnumcnst = 0; | ||
41 | f->protocnst = NULL; | ||
42 | f->nprotocnst = 0; | ||
39 | f->locvars = NULL; | 43 | f->locvars = NULL; |
40 | f->next = L->rootproto; | 44 | f->next = L->rootproto; |
41 | L->rootproto = f; | 45 | L->rootproto = f; |
@@ -49,7 +53,9 @@ void luaF_freeproto (lua_State *L, TProtoFunc *f) { | |||
49 | L->nblocks -= gcsizeproto(L, f); | 53 | L->nblocks -= gcsizeproto(L, f); |
50 | luaM_free(L, f->code); | 54 | luaM_free(L, f->code); |
51 | luaM_free(L, f->locvars); | 55 | luaM_free(L, f->locvars); |
52 | luaM_free(L, f->consts); | 56 | luaM_free(L, f->strcnst); |
57 | luaM_free(L, f->numcnst); | ||
58 | luaM_free(L, f->protocnst); | ||
53 | luaM_free(L, f); | 59 | luaM_free(L, f); |
54 | } | 60 | } |
55 | 61 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.38 1999/12/23 18:19:57 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.39 1999/12/27 17:33:22 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -33,8 +33,10 @@ static void protomark (lua_State *L, TProtoFunc *f) { | |||
33 | int i; | 33 | int i; |
34 | f->marked = 1; | 34 | f->marked = 1; |
35 | strmark(L, f->source); | 35 | strmark(L, f->source); |
36 | for (i=f->nconsts-1; i>=0; i--) | 36 | for (i=f->nstrcnst-1; i>=0; i--) |
37 | markobject(L, &f->consts[i]); | 37 | strmark(L, f->strcnst[i]); |
38 | for (i=f->nprotocnst-1; i>=0; i--) | ||
39 | protomark(L, f->protocnst[i]); | ||
38 | } | 40 | } |
39 | } | 41 | } |
40 | 42 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 1.42 1999/12/27 17:33:22 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.43 1999/12/29 16:31:15 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -154,14 +154,19 @@ typedef struct TaggedString { | |||
154 | typedef struct TProtoFunc { | 154 | typedef struct TProtoFunc { |
155 | struct TProtoFunc *next; | 155 | struct TProtoFunc *next; |
156 | int marked; | 156 | int marked; |
157 | struct TObject *consts; | 157 | struct TaggedString **strcnst; |
158 | int nconsts; | 158 | int nstrcnst; |
159 | real *numcnst; | ||
160 | int nnumcnst; | ||
161 | struct TProtoFunc **protocnst; | ||
162 | int nprotocnst; | ||
159 | Byte *code; /* ends with opcode ENDCODE */ | 163 | Byte *code; /* ends with opcode ENDCODE */ |
160 | int lineDefined; | 164 | int lineDefined; |
161 | TaggedString *source; | 165 | TaggedString *source; |
162 | struct LocVar *locvars; /* ends with line = -1 */ | 166 | struct LocVar *locvars; /* ends with line = -1 */ |
163 | } TProtoFunc; | 167 | } TProtoFunc; |
164 | 168 | ||
169 | |||
165 | typedef struct LocVar { | 170 | typedef struct LocVar { |
166 | TaggedString *varname; /* NULL signals end of scope */ | 171 | TaggedString *varname; /* NULL signals end of scope */ |
167 | int line; | 172 | int line; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.35 1999/12/27 17:33:22 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.36 1999/12/29 16:31:15 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -33,8 +33,10 @@ PUSHNUMBER,/* b - (float)b */ | |||
33 | PUSHNUMBERNEGW,/* w - (float)-w */ | 33 | PUSHNUMBERNEGW,/* w - (float)-w */ |
34 | PUSHNUMBERNEG,/* b - (float)-b */ | 34 | PUSHNUMBERNEG,/* b - (float)-b */ |
35 | 35 | ||
36 | PUSHCONSTANTW,/*w - CNST[w] */ | 36 | PUSHSTRCNSTW,/* w - STRCNST[w] */ |
37 | PUSHCONSTANT,/* b - CNST[b] */ | 37 | PUSHSTRCNST,/* b - STRCNST[b] */ |
38 | PUSHNUMCNSTW,/* w - NUMCNST[w] */ | ||
39 | PUSHNUMCNST,/* b - NUMCNST[b] */ | ||
38 | 40 | ||
39 | PUSHUPVALUE,/* b - Closure[b] */ | 41 | PUSHUPVALUE,/* b - Closure[b] */ |
40 | 42 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.53 2000/01/10 17:34:38 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.54 2000/01/12 16:24:39 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -209,33 +209,24 @@ static void code_opcode (LexState *ls, OpCode op, int delta) { | |||
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | static void code_constant (LexState *ls, int c) { | 212 | static void code_strcnst (LexState *ls, int c) { |
213 | code_oparg(ls, PUSHCONSTANT, c, 1); | 213 | code_oparg(ls, PUSHSTRCNST, c, 1); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | static void assertglobal (LexState *ls, int index) { | 217 | static void assertglobal (LexState *ls, int index) { |
218 | TObject *o = &ls->fs->f->consts[index]; | 218 | luaS_assertglobal(ls->L, ls->fs->f->strcnst[index]); |
219 | LUA_ASSERT(ls->L, ttype(o) == LUA_T_STRING, "global name is not a string"); | ||
220 | luaS_assertglobal(ls->L, tsvalue(o)); | ||
221 | } | ||
222 | |||
223 | |||
224 | static int next_constant (LexState *ls, TProtoFunc *f) { | ||
225 | luaM_growvector(ls->L, f->consts, f->nconsts, 1, | ||
226 | TObject, constantEM, MAX_ARG); | ||
227 | return f->nconsts++; | ||
228 | } | 219 | } |
229 | 220 | ||
230 | 221 | ||
231 | static int string_constant (LexState *ls, FuncState *fs, TaggedString *s) { | 222 | static int string_constant (LexState *ls, FuncState *fs, TaggedString *s) { |
232 | TProtoFunc *f = fs->f; | 223 | TProtoFunc *f = fs->f; |
233 | int c = s->constindex; | 224 | int c = s->constindex; |
234 | if (!(c < f->nconsts && | 225 | if (c >= f->nstrcnst || f->strcnst[c] != s) { |
235 | ttype(&f->consts[c]) == LUA_T_STRING && tsvalue(&f->consts[c]) == s)) { | 226 | luaM_growvector(ls->L, f->strcnst, f->nstrcnst, 1, |
236 | c = next_constant(ls, f); | 227 | TaggedString *, constantEM, MAX_ARG); |
237 | ttype(&f->consts[c]) = LUA_T_STRING; | 228 | c = f->nstrcnst++; |
238 | tsvalue(&f->consts[c]) = s; | 229 | f->strcnst[c] = s; |
239 | s->constindex = c; /* hint for next time */ | 230 | s->constindex = c; /* hint for next time */ |
240 | } | 231 | } |
241 | return c; | 232 | return c; |
@@ -243,7 +234,7 @@ static int string_constant (LexState *ls, FuncState *fs, TaggedString *s) { | |||
243 | 234 | ||
244 | 235 | ||
245 | static void code_string (LexState *ls, TaggedString *s) { | 236 | static void code_string (LexState *ls, TaggedString *s) { |
246 | code_constant(ls, string_constant(ls, ls->fs, s)); | 237 | code_strcnst(ls, string_constant(ls, ls->fs, s)); |
247 | } | 238 | } |
248 | 239 | ||
249 | 240 | ||
@@ -251,18 +242,15 @@ static void code_string (LexState *ls, TaggedString *s) { | |||
251 | static int real_constant (LexState *ls, real r) { | 242 | static int real_constant (LexState *ls, real r) { |
252 | /* check whether `r' has appeared within the last LIM entries */ | 243 | /* check whether `r' has appeared within the last LIM entries */ |
253 | TProtoFunc *f = ls->fs->f; | 244 | TProtoFunc *f = ls->fs->f; |
254 | TObject *cnt = f->consts; | 245 | int c = f->nnumcnst; |
255 | int c = f->nconsts; | ||
256 | int lim = c < LIM ? 0 : c-LIM; | 246 | int lim = c < LIM ? 0 : c-LIM; |
257 | while (--c >= lim) { | 247 | while (--c >= lim) |
258 | if (ttype(&cnt[c]) == LUA_T_NUMBER && nvalue(&cnt[c]) == r) | 248 | if (f->numcnst[c] == r) return c; |
259 | return c; | ||
260 | } | ||
261 | /* not found; create a new entry */ | 249 | /* not found; create a new entry */ |
262 | c = next_constant(ls, f); | 250 | luaM_growvector(ls->L, f->numcnst, f->nnumcnst, 1, |
263 | cnt = f->consts; /* `next_constant' may reallocate this vector */ | 251 | real, constantEM, MAX_ARG); |
264 | ttype(&cnt[c]) = LUA_T_NUMBER; | 252 | c = f->nnumcnst++; |
265 | nvalue(&cnt[c]) = r; | 253 | f->numcnst[c] = r; |
266 | return c; | 254 | return c; |
267 | } | 255 | } |
268 | 256 | ||
@@ -274,7 +262,7 @@ static void code_number (LexState *ls, real f) { | |||
274 | code_oparg(ls, (f<0) ? PUSHNUMBERNEG : PUSHNUMBER, (int)af, 1); | 262 | code_oparg(ls, (f<0) ? PUSHNUMBERNEG : PUSHNUMBER, (int)af, 1); |
275 | } | 263 | } |
276 | else | 264 | else |
277 | code_constant(ls, real_constant(ls, f)); | 265 | code_oparg(ls, PUSHNUMCNST, real_constant(ls, f), 1); |
278 | } | 266 | } |
279 | 267 | ||
280 | 268 | ||
@@ -476,7 +464,7 @@ static void code_args (LexState *ls, int nparams, int dots) { | |||
476 | static void unloaddot (LexState *ls, vardesc *v) { | 464 | static void unloaddot (LexState *ls, vardesc *v) { |
477 | /* dotted variables <a.x> must be stored as regular indexed vars <a["x"]> */ | 465 | /* dotted variables <a.x> must be stored as regular indexed vars <a["x"]> */ |
478 | if (v->k == VDOT) { | 466 | if (v->k == VDOT) { |
479 | code_constant(ls, v->info); | 467 | code_strcnst(ls, v->info); |
480 | v->k = VINDEXED; | 468 | v->k = VINDEXED; |
481 | } | 469 | } |
482 | } | 470 | } |
@@ -556,19 +544,16 @@ static void codeIf (LexState *ls, int thenAdd, int elseAdd) { | |||
556 | 544 | ||
557 | static void func_onstack (LexState *ls, FuncState *func) { | 545 | static void func_onstack (LexState *ls, FuncState *func) { |
558 | FuncState *fs = ls->fs; | 546 | FuncState *fs = ls->fs; |
547 | TProtoFunc *f = fs->f; | ||
559 | int i; | 548 | int i; |
560 | int c = next_constant(ls, fs->f); | 549 | luaM_growvector(ls->L, f->protocnst, f->nprotocnst, 1, |
561 | ttype(&fs->f->consts[c]) = LUA_T_LPROTO; | 550 | TProtoFunc *, constantEM, MAX_ARG); |
562 | fs->f->consts[c].value.tf = func->f; | 551 | f->protocnst[f->nprotocnst] = func->f; |
563 | if (func->nupvalues == 0) | 552 | for (i=0; i<func->nupvalues; i++) |
564 | code_constant(ls, c); | 553 | lua_pushvar(ls, &func->upvalues[i]); |
565 | else { | 554 | deltastack(ls, 1); /* CLOSURE puts one extra element (before poping) */ |
566 | for (i=0; i<func->nupvalues; i++) | 555 | code_oparg(ls, CLOSURE, f->nprotocnst++, -func->nupvalues); |
567 | lua_pushvar(ls, &func->upvalues[i]); | 556 | code_byte(ls, (Byte)func->nupvalues); |
568 | deltastack(ls, 1); /* CLOSURE puts one extra element (before poping) */ | ||
569 | code_oparg(ls, CLOSURE, c, -func->nupvalues); | ||
570 | code_byte(ls, (Byte)func->nupvalues); | ||
571 | } | ||
572 | } | 557 | } |
573 | 558 | ||
574 | 559 | ||
@@ -602,7 +587,9 @@ static void close_func (LexState *ls) { | |||
602 | code_opcode(ls, ENDCODE, 0); | 587 | code_opcode(ls, ENDCODE, 0); |
603 | f->code[0] = (Byte)fs->maxstacksize; | 588 | f->code[0] = (Byte)fs->maxstacksize; |
604 | luaM_reallocvector(ls->L, f->code, fs->pc, Byte); | 589 | luaM_reallocvector(ls->L, f->code, fs->pc, Byte); |
605 | luaM_reallocvector(ls->L, f->consts, f->nconsts, TObject); | 590 | luaM_reallocvector(ls->L, f->strcnst, f->nstrcnst, TaggedString *); |
591 | luaM_reallocvector(ls->L, f->numcnst, f->nnumcnst, real); | ||
592 | luaM_reallocvector(ls->L, f->protocnst, f->nprotocnst, TProtoFunc *); | ||
606 | if (fs->nvars != -1) { /* debug information? */ | 593 | if (fs->nvars != -1) { /* debug information? */ |
607 | luaI_registerlocalvar(ls, NULL, -1); /* flag end of vector */ | 594 | luaI_registerlocalvar(ls, NULL, -1); /* flag end of vector */ |
608 | luaM_reallocvector(ls->L, f->locvars, fs->nvars, LocVar); | 595 | luaM_reallocvector(ls->L, f->locvars, fs->nvars, LocVar); |
@@ -683,7 +670,7 @@ static int checkname (LexState *ls) { | |||
683 | 670 | ||
684 | static TaggedString *str_checkname (LexState *ls) { | 671 | static TaggedString *str_checkname (LexState *ls) { |
685 | int i = checkname(ls); /* this call may realloc `f->consts' */ | 672 | int i = checkname(ls); /* this call may realloc `f->consts' */ |
686 | return tsvalue(&ls->fs->f->consts[i]); | 673 | return ls->fs->f->strcnst[i]; |
687 | } | 674 | } |
688 | 675 | ||
689 | 676 | ||
@@ -875,7 +862,7 @@ static void recfield (LexState *ls) { | |||
875 | /* recfield -> (NAME | '['exp1']') = exp1 */ | 862 | /* recfield -> (NAME | '['exp1']') = exp1 */ |
876 | switch (ls->token) { | 863 | switch (ls->token) { |
877 | case NAME: | 864 | case NAME: |
878 | code_constant(ls, checkname(ls)); | 865 | code_strcnst(ls, checkname(ls)); |
879 | break; | 866 | break; |
880 | 867 | ||
881 | case '[': | 868 | case '[': |
@@ -939,7 +926,7 @@ static void constructor_part (LexState *ls, constdesc *cd) { | |||
939 | if (ls->token == '=') { | 926 | if (ls->token == '=') { |
940 | switch (v.k) { | 927 | switch (v.k) { |
941 | case VGLOBAL: | 928 | case VGLOBAL: |
942 | code_constant(ls, v.info); | 929 | code_strcnst(ls, v.info); |
943 | break; | 930 | break; |
944 | case VLOCAL: | 931 | case VLOCAL: |
945 | code_string(ls, ls->fs->localvar[v.info]); | 932 | code_string(ls, ls->fs->localvar[v.info]); |
@@ -1297,7 +1284,7 @@ static int funcname (LexState *ls, vardesc *v) { | |||
1297 | needself = (ls->token == ':'); | 1284 | needself = (ls->token == ':'); |
1298 | next(ls); | 1285 | next(ls); |
1299 | lua_pushvar(ls, v); | 1286 | lua_pushvar(ls, v); |
1300 | code_constant(ls, checkname(ls)); | 1287 | code_strcnst(ls, checkname(ls)); |
1301 | v->k = VINDEXED; | 1288 | v->k = VINDEXED; |
1302 | } | 1289 | } |
1303 | return needself; | 1290 | return needself; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.81 2000/01/19 16:50:30 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.82 2000/01/24 20:14:07 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -314,7 +314,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
314 | StkId base) { | 314 | StkId base) { |
315 | register StkId top; /* keep top local, for performance */ | 315 | register StkId top; /* keep top local, for performance */ |
316 | register const Byte *pc = tf->code; | 316 | register const Byte *pc = tf->code; |
317 | const TObject *consts = tf->consts; | 317 | TaggedString **strcnst = tf->strcnst; |
318 | if (L->callhook) | 318 | if (L->callhook) |
319 | luaD_callHook(L, base-1, L->callhook, "call"); | 319 | luaD_callHook(L, base-1, L->callhook, "call"); |
320 | luaD_checkstack(L, (*pc++)+EXTRA_STACK); | 320 | luaD_checkstack(L, (*pc++)+EXTRA_STACK); |
@@ -372,9 +372,18 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
372 | top++; | 372 | top++; |
373 | break; | 373 | break; |
374 | 374 | ||
375 | case PUSHCONSTANTW: aux += highbyte(L, *pc++); | 375 | case PUSHSTRCNSTW: aux += highbyte(L, *pc++); |
376 | case PUSHCONSTANT: aux += *pc++; | 376 | case PUSHSTRCNST: aux += *pc++; |
377 | *top++ = consts[aux]; | 377 | ttype(top) = LUA_T_STRING; |
378 | tsvalue(top) = strcnst[aux]; | ||
379 | top++; | ||
380 | break; | ||
381 | |||
382 | case PUSHNUMCNSTW: aux += highbyte(L, *pc++); | ||
383 | case PUSHNUMCNST: aux += *pc++; | ||
384 | ttype(top) = LUA_T_NUMBER; | ||
385 | nvalue(top) = tf->numcnst[aux]; | ||
386 | top++; | ||
378 | break; | 387 | break; |
379 | 388 | ||
380 | case PUSHUPVALUE: aux = *pc++; | 389 | case PUSHUPVALUE: aux = *pc++; |
@@ -387,8 +396,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
387 | 396 | ||
388 | case GETGLOBALW: aux += highbyte(L, *pc++); | 397 | case GETGLOBALW: aux += highbyte(L, *pc++); |
389 | case GETGLOBAL: aux += *pc++; | 398 | case GETGLOBAL: aux += *pc++; |
390 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | 399 | luaV_getglobal(L, strcnst[aux]->u.s.gv, top); |
391 | luaV_getglobal(L, tsvalue(&consts[aux])->u.s.gv, top); | ||
392 | top++; | 400 | top++; |
393 | break; | 401 | break; |
394 | 402 | ||
@@ -399,9 +407,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
399 | 407 | ||
400 | case GETDOTTEDW: aux += highbyte(L, *pc++); | 408 | case GETDOTTEDW: aux += highbyte(L, *pc++); |
401 | case GETDOTTED: aux += *pc++; | 409 | case GETDOTTED: aux += *pc++; |
402 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | ||
403 | ttype(top) = LUA_T_STRING; | 410 | ttype(top) = LUA_T_STRING; |
404 | tsvalue(top++) = tsvalue(&consts[aux]); | 411 | tsvalue(top++) = strcnst[aux]; |
405 | luaV_gettable(L, top); | 412 | luaV_gettable(L, top); |
406 | top--; | 413 | top--; |
407 | break; | 414 | break; |
@@ -410,9 +417,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
410 | case PUSHSELF: aux += *pc++; { | 417 | case PUSHSELF: aux += *pc++; { |
411 | TObject receiver; | 418 | TObject receiver; |
412 | receiver = *(top-1); | 419 | receiver = *(top-1); |
413 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | ||
414 | ttype(top) = LUA_T_STRING; | 420 | ttype(top) = LUA_T_STRING; |
415 | tsvalue(top++) = tsvalue(&consts[aux]); | 421 | tsvalue(top++) = strcnst[aux]; |
416 | luaV_gettable(L, top); | 422 | luaV_gettable(L, top); |
417 | *(top-1) = receiver; | 423 | *(top-1) = receiver; |
418 | break; | 424 | break; |
@@ -433,8 +439,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
433 | 439 | ||
434 | case SETGLOBALW: aux += highbyte(L, *pc++); | 440 | case SETGLOBALW: aux += highbyte(L, *pc++); |
435 | case SETGLOBAL: aux += *pc++; | 441 | case SETGLOBAL: aux += *pc++; |
436 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | 442 | luaV_setglobal(L, strcnst[aux]->u.s.gv, top); |
437 | luaV_setglobal(L, tsvalue(&consts[aux])->u.s.gv, top); | ||
438 | top--; | 443 | top--; |
439 | break; | 444 | break; |
440 | 445 | ||
@@ -626,10 +631,10 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
626 | 631 | ||
627 | case CLOSUREW: aux += highbyte(L, *pc++); | 632 | case CLOSUREW: aux += highbyte(L, *pc++); |
628 | case CLOSURE: aux += *pc++; | 633 | case CLOSURE: aux += *pc++; |
629 | *top++ = consts[aux]; | 634 | ttype(top) = LUA_T_LPROTO; |
630 | L->top = top; | 635 | tfvalue(top) = tf->protocnst[aux]; |
636 | L->top = ++top; | ||
631 | aux = *pc++; /* number of upvalues */ | 637 | aux = *pc++; /* number of upvalues */ |
632 | LUA_ASSERT(L, aux>0, "closure with no upvalues"); | ||
633 | luaV_closure(L, aux); | 638 | luaV_closure(L, aux); |
634 | luaC_checkGC(L); | 639 | luaC_checkGC(L); |
635 | top -= aux; | 640 | top -= aux; |