Try to code a binary operator negating its second operand. ** For the metamethod, 2nd operand must keep its original value. */
| 1543 | ** For the metamethod, 2nd operand must keep its original value. |
| 1544 | */ |
| 1545 | static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, |
| 1546 | OpCode op, int line, TMS event) { |
| 1547 | if (!isKint(e2)) |
| 1548 | return 0; /* not an integer constant */ |
| 1549 | else { |
| 1550 | lua_Integer i2 = e2->u.ival; |
| 1551 | if (!(fitsC(i2) && fitsC(-i2))) |
| 1552 | return 0; /* not in the proper range */ |
| 1553 | else { /* operating a small integer constant */ |
| 1554 | int v2 = cast_int(i2); |
| 1555 | finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event); |
| 1556 | /* correct metamethod argument */ |
| 1557 | SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2)); |
| 1558 | return 1; /* successfully coded */ |
| 1559 | } |
| 1560 | } |
| 1561 | } |
| 1562 | |
| 1563 | |
| 1564 | static void swapexps (expdesc *e1, expdesc *e2) { |
no test coverage detected