Try to code a binary operator negating its second operand. ** For the metamethod, 2nd operand must keep its original value. */
| 1414 | ** For the metamethod, 2nd operand must keep its original value. |
| 1415 | */ |
| 1416 | static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, |
| 1417 | OpCode op, int line, TMS event) { |
| 1418 | if (!luaK_isKint(e2)) |
| 1419 | return 0; /* not an integer constant */ |
| 1420 | else { |
| 1421 | lua_Integer i2 = e2->u.ival; |
| 1422 | if (!(fitsC(i2) && fitsC(-i2))) |
| 1423 | return 0; /* not in the proper range */ |
| 1424 | else { /* operating a small integer constant */ |
| 1425 | int v2 = cast_int(i2); |
| 1426 | finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event); |
| 1427 | /* correct metamethod argument */ |
| 1428 | SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2)); |
| 1429 | return 1; /* successfully coded */ |
| 1430 | } |
| 1431 | } |
| 1432 | } |
| 1433 | |
| 1434 | |
| 1435 | static void swapexps (expdesc *e1, expdesc *e2) { |
no test coverage detected