aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/lvm.c b/lvm.c
index 6c4bab08..457da1dd 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.313 2017/11/21 14:17:35 roberto Exp $ 2** $Id: lvm.c,v 2.314 2017/11/22 18:41:20 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*/
@@ -715,7 +715,7 @@ void luaV_finishOp (lua_State *L) {
715 res = !res; /* negate result */ 715 res = !res; /* negate result */
716 } 716 }
717 lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); 717 lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
718 if (res != GETARG_A(inst)) /* condition failed? */ 718 if (res != GETARG_B(inst)) /* condition failed? */
719 ci->u.l.savedpc++; /* skip jump instruction */ 719 ci->u.l.savedpc++; /* skip jump instruction */
720 break; 720 break;
721 } 721 }
@@ -1340,64 +1340,59 @@ void luaV_execute (lua_State *L) {
1340 vmbreak; 1340 vmbreak;
1341 } 1341 }
1342 vmcase(OP_EQ) { 1342 vmcase(OP_EQ) {
1343 TValue *rb = vRB(i);
1344 TValue *rc = vRC(i); 1343 TValue *rc = vRC(i);
1345 int res; 1344 int res;
1346 Protect(res = luaV_equalobj(L, rb, rc)); 1345 Protect(res = luaV_equalobj(L, s2v(ra), rc));
1347 if (res != GETARG_A(i)) 1346 if (res != GETARG_B(i))
1348 pc++; 1347 pc++;
1349 else 1348 else
1350 donextjump(ci); 1349 donextjump(ci);
1351 vmbreak; 1350 vmbreak;
1352 } 1351 }
1353 vmcase(OP_LT) { 1352 vmcase(OP_LT) {
1354 TValue *rb = vRB(i);
1355 TValue *rc = vRC(i); 1353 TValue *rc = vRC(i);
1356 int res; 1354 int res;
1357 if (ttisinteger(rb) && ttisinteger(rc)) 1355 if (ttisinteger(s2v(ra)) && ttisinteger(rc))
1358 res = (ivalue(rb) < ivalue(rc)); 1356 res = (ivalue(s2v(ra)) < ivalue(rc));
1359 else if (ttisnumber(rb) && ttisnumber(rc)) 1357 else if (ttisnumber(s2v(ra)) && ttisnumber(rc))
1360 res = LTnum(rb, rc); 1358 res = LTnum(s2v(ra), rc);
1361 else 1359 else
1362 Protect(res = lessthanothers(L, rb, rc)); 1360 Protect(res = lessthanothers(L, s2v(ra), rc));
1363 if (res != GETARG_A(i)) 1361 if (res != GETARG_B(i))
1364 pc++; 1362 pc++;
1365 else 1363 else
1366 donextjump(ci); 1364 donextjump(ci);
1367 vmbreak; 1365 vmbreak;
1368 } 1366 }
1369 vmcase(OP_LE) { 1367 vmcase(OP_LE) {
1370 TValue *rb = vRB(i);
1371 TValue *rc = vRC(i); 1368 TValue *rc = vRC(i);
1372 int res; 1369 int res;
1373 if (ttisinteger(rb) && ttisinteger(rc)) 1370 if (ttisinteger(s2v(ra)) && ttisinteger(rc))
1374 res = (ivalue(rb) <= ivalue(rc)); 1371 res = (ivalue(s2v(ra)) <= ivalue(rc));
1375 else if (ttisnumber(rb) && ttisnumber(rc)) 1372 else if (ttisnumber(s2v(ra)) && ttisnumber(rc))
1376 res = LEnum(rb, rc); 1373 res = LEnum(s2v(ra), rc);
1377 else 1374 else
1378 Protect(res = lessequalothers(L, rb, rc)); 1375 Protect(res = lessequalothers(L, s2v(ra), rc));
1379 if (res != GETARG_A(i)) 1376 if (res != GETARG_B(i))
1380 pc++; 1377 pc++;
1381 else 1378 else
1382 donextjump(ci); 1379 donextjump(ci);
1383 vmbreak; 1380 vmbreak;
1384 } 1381 }
1385 vmcase(OP_EQK) { 1382 vmcase(OP_EQK) {
1386 TValue *rb = vRB(i);
1387 TValue *rc = KC(i); 1383 TValue *rc = KC(i);
1388 /* basic types do not use '__eq'; we can use raw equality */ 1384 /* basic types do not use '__eq'; we can use raw equality */
1389 if (luaV_equalobj(NULL, rb, rc) != GETARG_A(i)) 1385 if (luaV_equalobj(NULL, s2v(ra), rc) != GETARG_B(i))
1390 pc++; 1386 pc++;
1391 else 1387 else
1392 donextjump(ci); 1388 donextjump(ci);
1393 vmbreak; 1389 vmbreak;
1394 } 1390 }
1395 vmcase(OP_EQI) { 1391 vmcase(OP_EQI) {
1396 TValue *rb = vRB(i);
1397 int ic = GETARG_sC(i); 1392 int ic = GETARG_sC(i);
1398 if ((ttisinteger(rb) ? (ivalue(rb) == ic) 1393 if ((ttisinteger(s2v(ra)) ? (ivalue(s2v(ra)) == ic)
1399 :ttisfloat(rb) ? luai_numeq(fltvalue(rb), cast_num(ic)) 1394 :ttisfloat(s2v(ra)) ? luai_numeq(fltvalue(s2v(ra)), cast_num(ic))
1400 : 0) != GETARG_A(i)) 1395 : 0) != GETARG_B(i))
1401 pc++; 1396 pc++;
1402 else 1397 else
1403 donextjump(ci); 1398 donextjump(ci);