Keep the order left-right in shifts

Opcodes OP_SHLI-OP_SHRI and the cases for opcodes OP_SHL-OP_SHR were
out of order.
This commit is contained in:
Roberto I
2025-08-20 14:31:07 -03:00
parent c688b00f73
commit 88aa4049ad
5 changed files with 18 additions and 18 deletions

28
lvm.c
View File

@@ -1476,16 +1476,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
op_bitwiseK(L, l_bxor);
vmbreak;
}
vmcase(OP_SHRI) {
StkId ra = RA(i);
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
}
vmbreak;
}
vmcase(OP_SHLI) {
StkId ra = RA(i);
TValue *rb = vRB(i);
@@ -1496,6 +1486,16 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
}
vmbreak;
}
vmcase(OP_SHRI) {
StkId ra = RA(i);
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
}
vmbreak;
}
vmcase(OP_ADD) {
op_arith(L, l_addi, luai_numadd);
vmbreak;
@@ -1538,14 +1538,14 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
op_bitwise(L, l_bxor);
vmbreak;
}
vmcase(OP_SHR) {
op_bitwise(L, luaV_shiftr);
vmbreak;
}
vmcase(OP_SHL) {
op_bitwise(L, luaV_shiftl);
vmbreak;
}
vmcase(OP_SHR) {
op_bitwise(L, luaV_shiftr);
vmbreak;
}
vmcase(OP_MMBIN) {
StkId ra = RA(i);
Instruction pi = *(pc - 2); /* original arith. expression */