aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-13 16:32:09 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-13 16:32:09 -0200
commit86431a2f1c668844c665f9d09e246de906b511d8 (patch)
tree643d503667b624d4faeecd6bed6cc51f9084cb00 /lvm.c
parent36cf8f3a3c44da00cc9255797153df3c02895379 (diff)
downloadlua-86431a2f1c668844c665f9d09e246de906b511d8.tar.gz
lua-86431a2f1c668844c665f9d09e246de906b511d8.tar.bz2
lua-86431a2f1c668844c665f9d09e246de906b511d8.zip
new opcodes BANDK/BORK/BXORK. (They do not use immediate operands
because, too often, masks in bitwise operations are integers larger than one byte.)
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/lvm.c b/lvm.c
index 9cbba4a9..90fd1060 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.323 2017/11/30 13:29:18 roberto Exp roberto $ 2** $Id: lvm.c,v 2.324 2017/12/04 17:41:30 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*/
@@ -687,6 +687,7 @@ void luaV_finishOp (lua_State *L) {
687 case OP_MODI: case OP_POWI: 687 case OP_MODI: case OP_POWI:
688 case OP_ADD: case OP_SUB: 688 case OP_ADD: case OP_SUB:
689 case OP_MUL: case OP_DIV: case OP_IDIV: 689 case OP_MUL: case OP_DIV: case OP_IDIV:
690 case OP_BANDK: case OP_BORK: case OP_BXORK:
690 case OP_BAND: case OP_BOR: case OP_BXOR: 691 case OP_BAND: case OP_BOR: case OP_BXOR:
691 case OP_SHRI: case OP_SHL: case OP_SHR: 692 case OP_SHRI: case OP_SHL: case OP_SHR:
692 case OP_MOD: case OP_POW: 693 case OP_MOD: case OP_POW:
@@ -1182,6 +1183,39 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1182 Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); 1183 Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV));
1183 vmbreak; 1184 vmbreak;
1184 } 1185 }
1186 vmcase(OP_BANDK) {
1187 TValue *p1 = vRB(i);
1188 TValue *p2 = KC(i);
1189 lua_Integer i1;
1190 if (tointegerns(p1, &i1)) {
1191 setivalue(vra, intop(&, i1, ivalue(p2)));
1192 }
1193 else
1194 Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BAND));
1195 vmbreak;
1196 }
1197 vmcase(OP_BORK) {
1198 TValue *p1 = vRB(i);
1199 TValue *p2 = KC(i);
1200 lua_Integer i1;
1201 if (tointegerns(p1, &i1)) {
1202 setivalue(vra, intop(|, i1, ivalue(p2)));
1203 }
1204 else
1205 Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BOR));
1206 vmbreak;
1207 }
1208 vmcase(OP_BXORK) {
1209 TValue *p1 = vRB(i);
1210 TValue *p2 = KC(i);
1211 lua_Integer i1;
1212 if (tointegerns(p1, &i1)) {
1213 setivalue(vra, intop(^, i1, ivalue(p2)));
1214 }
1215 else
1216 Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BXOR));
1217 vmbreak;
1218 }
1185 vmcase(OP_BAND) { 1219 vmcase(OP_BAND) {
1186 TValue *rb = vRB(i); 1220 TValue *rb = vRB(i);
1187 TValue *rc = vRC(i); 1221 TValue *rc = vRC(i);