aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c2
-rw-r--r--lobject.c2
-rw-r--r--ltm.c2
-rw-r--r--lvm.c19
4 files changed, 9 insertions, 16 deletions
diff --git a/lapi.c b/lapi.c
index a9ffad80..0ea3dc0f 100644
--- a/lapi.c
+++ b/lapi.c
@@ -329,14 +329,12 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
329 o1 = index2value(L, index1); 329 o1 = index2value(L, index1);
330 o2 = index2value(L, index2); 330 o2 = index2value(L, index2);
331 if (isvalid(L, o1) && isvalid(L, o2)) { 331 if (isvalid(L, o1) && isvalid(L, o2)) {
332 ptrdiff_t top = savestack(L, L->top);
333 switch (op) { 332 switch (op) {
334 case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; 333 case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break;
335 case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; 334 case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
336 case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; 335 case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
337 default: api_check(L, 0, "invalid option"); 336 default: api_check(L, 0, "invalid option");
338 } 337 }
339 L->top = restorestack(L, top);
340 } 338 }
341 lua_unlock(L); 339 lua_unlock(L);
342 return i; 340 return i;
diff --git a/lobject.c b/lobject.c
index b376ab15..b4efae4f 100644
--- a/lobject.c
+++ b/lobject.c
@@ -127,9 +127,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
127 StkId res) { 127 StkId res) {
128 if (!luaO_rawarith(L, op, p1, p2, s2v(res))) { 128 if (!luaO_rawarith(L, op, p1, p2, s2v(res))) {
129 /* could not perform raw operation; try metamethod */ 129 /* could not perform raw operation; try metamethod */
130 ptrdiff_t top = savestack(L, L->top);
131 luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD)); 130 luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
132 L->top = restorestack(L, top);
133 } 131 }
134} 132}
135 133
diff --git a/ltm.c b/ltm.c
index 991e62c1..1e32d86a 100644
--- a/ltm.c
+++ b/ltm.c
@@ -147,7 +147,6 @@ static int callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
147 147
148void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 148void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
149 StkId res, TMS event) { 149 StkId res, TMS event) {
150 L->top = L->ci->top;
151 if (!callbinTM(L, p1, p2, res, event)) { 150 if (!callbinTM(L, p1, p2, res, event)) {
152 switch (event) { 151 switch (event) {
153 case TM_BAND: case TM_BOR: case TM_BXOR: 152 case TM_BAND: case TM_BOR: case TM_BXOR:
@@ -191,7 +190,6 @@ void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
191 190
192int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, 191int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
193 TMS event) { 192 TMS event) {
194 L->top = L->ci->top;
195 if (callbinTM(L, p1, p2, L->top, event)) /* try original event */ 193 if (callbinTM(L, p1, p2, L->top, event)) /* try original event */
196 return !l_isfalse(s2v(L->top)); 194 return !l_isfalse(s2v(L->top));
197#if defined(LUA_COMPAT_LT_LE) 195#if defined(LUA_COMPAT_LT_LE)
diff --git a/lvm.c b/lvm.c
index 71f6ae0d..46150ef0 100644
--- a/lvm.c
+++ b/lvm.c
@@ -516,7 +516,6 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
516 if (tm == NULL) /* no TM? */ 516 if (tm == NULL) /* no TM? */
517 return 0; /* objects are different */ 517 return 0; /* objects are different */
518 else { 518 else {
519 L->top = L->ci->top;
520 luaT_callTMres(L, tm, t1, t2, L->top); /* call TM */ 519 luaT_callTMres(L, tm, t1, t2, L->top); /* call TM */
521 return !l_isfalse(s2v(L->top)); 520 return !l_isfalse(s2v(L->top));
522 } 521 }
@@ -925,7 +924,7 @@ void luaV_finishOp (lua_State *L) {
925 else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) \ 924 else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) \
926 cond = opf(s2v(ra), rb); \ 925 cond = opf(s2v(ra), rb); \
927 else \ 926 else \
928 ProtectNT(cond = other(L, s2v(ra), rb)); \ 927 Protect(cond = other(L, s2v(ra), rb)); \
929 docondjump(); } 928 docondjump(); }
930 929
931 930
@@ -944,7 +943,7 @@ void luaV_finishOp (lua_State *L) {
944 } \ 943 } \
945 else { \ 944 else { \
946 int isf = GETARG_C(i); \ 945 int isf = GETARG_C(i); \
947 ProtectNT(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm)); \ 946 Protect(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm)); \
948 } \ 947 } \
949 docondjump(); } 948 docondjump(); }
950 949
@@ -989,7 +988,7 @@ void luaV_finishOp (lua_State *L) {
989 988
990 989
991/* for test instructions, execute the jump instruction that follows it */ 990/* for test instructions, execute the jump instruction that follows it */
992#define donextjump(ci) { i = *pc; dojump(ci, i, 1); } 991#define donextjump(ci) { Instruction ni = *pc; dojump(ci, ni, 1); }
993 992
994/* 993/*
995** do a conditional jump: skip next instruction if 'cond' is not what 994** do a conditional jump: skip next instruction if 'cond' is not what
@@ -1408,7 +1407,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1408 TMS tm = (TMS)GETARG_C(i); 1407 TMS tm = (TMS)GETARG_C(i);
1409 StkId result = RA(pi); 1408 StkId result = RA(pi);
1410 lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR); 1409 lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
1411 ProtectNT(luaT_trybinTM(L, s2v(ra), rb, result, tm)); 1410 Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
1412 vmbreak; 1411 vmbreak;
1413 } 1412 }
1414 vmcase(OP_MMBINI) { 1413 vmcase(OP_MMBINI) {
@@ -1417,7 +1416,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1417 TMS tm = (TMS)GETARG_C(i); 1416 TMS tm = (TMS)GETARG_C(i);
1418 int flip = GETARG_k(i); 1417 int flip = GETARG_k(i);
1419 StkId result = RA(pi); 1418 StkId result = RA(pi);
1420 ProtectNT(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm)); 1419 Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
1421 vmbreak; 1420 vmbreak;
1422 } 1421 }
1423 vmcase(OP_MMBINK) { 1422 vmcase(OP_MMBINK) {
@@ -1426,7 +1425,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1426 TMS tm = (TMS)GETARG_C(i); 1425 TMS tm = (TMS)GETARG_C(i);
1427 int flip = GETARG_k(i); 1426 int flip = GETARG_k(i);
1428 StkId result = RA(pi); 1427 StkId result = RA(pi);
1429 ProtectNT(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm)); 1428 Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
1430 vmbreak; 1429 vmbreak;
1431 } 1430 }
1432 vmcase(OP_UNM) { 1431 vmcase(OP_UNM) {
@@ -1440,7 +1439,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1440 setfltvalue(s2v(ra), luai_numunm(L, nb)); 1439 setfltvalue(s2v(ra), luai_numunm(L, nb));
1441 } 1440 }
1442 else 1441 else
1443 ProtectNT(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); 1442 Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
1444 vmbreak; 1443 vmbreak;
1445 } 1444 }
1446 vmcase(OP_BNOT) { 1445 vmcase(OP_BNOT) {
@@ -1450,7 +1449,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1450 setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib)); 1449 setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
1451 } 1450 }
1452 else 1451 else
1453 ProtectNT(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); 1452 Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
1454 vmbreak; 1453 vmbreak;
1455 } 1454 }
1456 vmcase(OP_NOT) { 1455 vmcase(OP_NOT) {
@@ -1486,7 +1485,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1486 vmcase(OP_EQ) { 1485 vmcase(OP_EQ) {
1487 int cond; 1486 int cond;
1488 TValue *rb = vRB(i); 1487 TValue *rb = vRB(i);
1489 ProtectNT(cond = luaV_equalobj(L, s2v(ra), rb)); 1488 Protect(cond = luaV_equalobj(L, s2v(ra), rb));
1490 docondjump(); 1489 docondjump();
1491 vmbreak; 1490 vmbreak;
1492 } 1491 }