aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/lcode.c b/lcode.c
index 084354fd..ec255a0f 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.47 2010/06/30 14:11:17 roberto Exp roberto $ 2** $Id: lcode.c,v 2.48 2010/07/02 20:42:40 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -373,15 +373,13 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
373 break; 373 break;
374 } 374 }
375 case VINDEXED: { 375 case VINDEXED: {
376 OpCode op = OP_GETTABUP; /* assume 't' is in an upvalue */
376 freereg(fs, e->u.ind.idx); 377 freereg(fs, e->u.ind.idx);
377 freereg(fs, e->u.ind.t); 378 if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */
378 e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); 379 freereg(fs, e->u.ind.t);
379 e->k = VRELOCABLE; 380 op = OP_GETTABLE;
380 break; 381 }
381 } 382 e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx);
382 case VINDEXEDUP: {
383 freereg(fs, e->u.ind.idx);
384 e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx);
385 e->k = VRELOCABLE; 383 e->k = VRELOCABLE;
386 break; 384 break;
387 } 385 }
@@ -551,13 +549,9 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
551 break; 549 break;
552 } 550 }
553 case VINDEXED: { 551 case VINDEXED: {
552 OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP;
554 int e = luaK_exp2RK(fs, ex); 553 int e = luaK_exp2RK(fs, ex);
555 luaK_codeABC(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, e); 554 luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
556 break;
557 }
558 case VINDEXEDUP: {
559 int e = luaK_exp2RK(fs, ex);
560 luaK_codeABC(fs, OP_SETTABUP, var->u.ind.t, var->u.ind.idx, e);
561 break; 555 break;
562 } 556 }
563 default: { 557 default: {
@@ -705,7 +699,9 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
705 lua_assert(!hasjumps(t)); 699 lua_assert(!hasjumps(t));
706 t->u.ind.t = t->u.info; 700 t->u.ind.t = t->u.info;
707 t->u.ind.idx = luaK_exp2RK(fs, k); 701 t->u.ind.idx = luaK_exp2RK(fs, k);
708 t->k = (t->k == VUPVAL) ? VINDEXEDUP : VINDEXED; 702 t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL
703 : check_exp(vkisinreg(t->k), VLOCAL);
704 t->k = VINDEXED;
709} 705}
710 706
711 707