Added opcodes for arithmetic with K operands

Added opcodes for all seven arithmetic operators with K operands
(that is, operands that are numbers in the array of constants of
the function). They cover the cases of constant float operands
(e.g., 'x + .0.0', 'x^0.5') and large integer operands (e.g.,
'x % 10000').
This commit is contained in:
Roberto Ierusalimschy
2018-11-23 12:23:45 -02:00
parent 35296e1fde
commit 84e32ad2eb
11 changed files with 234 additions and 93 deletions

View File

@@ -610,12 +610,18 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
tm = TM_NEWINDEX;
break;
case OP_ADDI: case OP_SUBI: case OP_MULI: case OP_MODI:
case OP_POWI: case OP_DIVI: case OP_IDIVI:
case OP_BANDK: case OP_BORK: case OP_BXORK: {
case OP_POWI: case OP_DIVI: case OP_IDIVI: {
int offset = GET_OPCODE(i) - OP_ADDI; /* ORDER OP */
tm = cast(TMS, offset + TM_ADD); /* ORDER TM */
break;
}
case OP_ADDK: case OP_SUBK: case OP_MULK: case OP_MODK:
case OP_POWK: case OP_DIVK: case OP_IDIVK:
case OP_BANDK: case OP_BORK: case OP_BXORK: {
int offset = GET_OPCODE(i) - OP_ADDK; /* ORDER OP */
tm = cast(TMS, offset + TM_ADD); /* ORDER TM */
break;
}
case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD:
case OP_POW: case OP_DIV: case OP_IDIV: case OP_BAND:
case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: {