Try to code a binary operator negating its second operand. ** For the metamethod, 2nd operand must keep its original value. */
| 1461 | ** For the metamethod, 2nd operand must keep its original value. |
| 1462 | */ |
| 1463 | static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, |
| 1464 | OpCode op, int line, TMS event) { |
| 1465 | if (!isKint(e2)) |
| 1466 | return 0; /* not an integer constant */ |
| 1467 | else { |
| 1468 | lua_Integer i2 = e2->u.ival; |
| 1469 | if (!(fitsC(i2) && fitsC(-i2))) |
| 1470 | return 0; /* not in the proper range */ |
| 1471 | else { /* operating a small integer constant */ |
| 1472 | int v2 = cast_int(i2); |
| 1473 | finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event); |
| 1474 | /* correct metamethod argument */ |
| 1475 | SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2)); |
| 1476 | return 1; /* successfully coded */ |
| 1477 | } |
| 1478 | } |
| 1479 | } |
| 1480 | |
| 1481 | |
| 1482 | static void swapexps (expdesc *e1, expdesc *e2) { |
no test coverage detected