aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c12
-rw-r--r--lvm.c20
2 files changed, 17 insertions, 15 deletions
diff --git a/lapi.c b/lapi.c
index f66ec097..4902be21 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.208 2002/08/06 17:06:56 roberto Exp roberto $ 2** $Id: lapi.c,v 1.209 2002/08/06 18:54:18 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -747,15 +747,15 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
747 747
748 748
749LUA_API int lua_pushupvalues (lua_State *L) { 749LUA_API int lua_pushupvalues (lua_State *L) {
750 TObject *func; 750 Closure *func;
751 int n, i; 751 int n, i;
752 lua_lock(L); 752 lua_lock(L);
753 func = (L->ci->base - 1); 753 api_check(L, iscfunction(L->ci->base - 1));
754 api_check(L, iscfunction(func)); 754 func = clvalue(L->ci->base - 1);
755 n = clvalue(func)->c.nupvalues; 755 n = func->c.nupvalues;
756 luaD_checkstack(L, n + LUA_MINSTACK); 756 luaD_checkstack(L, n + LUA_MINSTACK);
757 for (i=0; i<n; i++) { 757 for (i=0; i<n; i++) {
758 setobj(L->top, &clvalue(func)->c.upvalue[i]); 758 setobj(L->top, &func->c.upvalue[i]);
759 L->top++; 759 L->top++;
760 } 760 }
761 lua_unlock(L); 761 lua_unlock(L);
diff --git a/lvm.c b/lvm.c
index 071b1d0f..3eeb2ff8 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.248 2002/07/17 16:25:13 roberto Exp $ 2** $Id: lvm.c,v 1.249 2002/08/05 17:36:24 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*/
@@ -385,10 +385,12 @@ StkId luaV_execute (lua_State *L) {
385 /* main loop of interpreter */ 385 /* main loop of interpreter */
386 for (;;) { 386 for (;;) {
387 const Instruction i = *pc++; 387 const Instruction i = *pc++;
388 const StkId ra = RA(i); 388 StkId ra;
389 if (L->hookmask >= LUA_MASKLINE && 389 if (L->hookmask >= LUA_MASKLINE &&
390 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) 390 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE))
391 traceexec(L); 391 traceexec(L);
392 /* warning!! several calls may realloc the stack and invalidate `ra' */
393 ra = RA(i);
392 lua_assert(L->top <= L->stack + L->stacksize && L->top >= L->ci->base); 394 lua_assert(L->top <= L->stack + L->stacksize && L->top >= L->ci->base);
393 lua_assert(L->top == L->ci->top || 395 lua_assert(L->top == L->ci->top ||
394 GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || 396 GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
@@ -544,7 +546,7 @@ StkId luaV_execute (lua_State *L) {
544 int b = GETARG_B(i); 546 int b = GETARG_B(i);
545 int c = GETARG_C(i); 547 int c = GETARG_C(i);
546 luaV_concat(L, c-b+1, c); /* may change `base' (and `ra') */ 548 luaV_concat(L, c-b+1, c); /* may change `base' (and `ra') */
547 setobj(base+GETARG_A(i), base+b); 549 setobj(RA(i), base+b);
548 luaV_checkGC(L, base+c+1); 550 luaV_checkGC(L, base+c+1);
549 break; 551 break;
550 } 552 }
@@ -634,13 +636,13 @@ StkId luaV_execute (lua_State *L) {
634 return ra; /* no: return */ 636 return ra; /* no: return */
635 else { /* yes: continue its execution (go through) */ 637 else { /* yes: continue its execution (go through) */
636 int nresults; 638 int nresults;
637 lua_assert(ttisfunction(ci->base-1)); 639 lua_assert(ttisfunction(ci->base - 1));
638 ci->pc = &pc; /* function is active again */ 640 lua_assert(GET_OPCODE(*(ci->u.l.savedpc - 1)) == OP_CALL);
639 pc = ci->u.l.savedpc; 641 nresults = GETARG_C(*(ci->u.l.savedpc - 1)) - 1;
640 lua_assert(GET_OPCODE(*(pc-1)) == OP_CALL);
641 nresults = GETARG_C(*(pc-1)) - 1;
642 luaD_poscall(L, nresults, ra); 642 luaD_poscall(L, nresults, ra);
643 if (nresults >= 0) L->top = L->ci->top; 643 if (nresults >= 0) L->top = L->ci->top;
644 L->ci->pc = &pc; /* function is active again */
645 pc = L->ci->u.l.savedpc;
644 goto retentry; 646 goto retentry;
645 } 647 }
646 } 648 }
@@ -670,7 +672,7 @@ StkId luaV_execute (lua_State *L) {
670 L->top = ra+5; 672 L->top = ra+5;
671 luaD_call(L, ra+2, GETARG_C(i) + 1); 673 luaD_call(L, ra+2, GETARG_C(i) + 1);
672 L->top = L->ci->top; 674 L->top = L->ci->top;
673 if (ttisnil(ra+2)) pc++; /* skip jump (break loop) */ 675 if (ttisnil(RA(i)+2)) pc++; /* skip jump (break loop) */
674 else dojump(pc, GETARG_sBx(*pc) + 1); /* else jump back */ 676 else dojump(pc, GETARG_sBx(*pc) + 1); /* else jump back */
675 break; 677 break;
676 } 678 }