| 372 | |
| 373 | |
| 374 | LUA_API void lua_arith (lua_State *L, int op) { |
| 375 | lua_lock(L); |
| 376 | if (op != LUA_OPUNM && op != LUA_OPBNOT) |
| 377 | api_checkpop(L, 2); /* all other operations expect two operands */ |
| 378 | else { /* for unary operations, add fake 2nd operand */ |
| 379 | api_checkpop(L, 1); |
| 380 | setobjs2s(L, L->top.p, L->top.p - 1); |
| 381 | api_incr_top(L); |
| 382 | } |
| 383 | /* first operand at top - 2, second at top - 1; result go to top - 2 */ |
| 384 | luaO_arith(L, op, s2v(L->top.p - 2), s2v(L->top.p - 1), L->top.p - 2); |
| 385 | L->top.p--; /* pop second operand */ |
| 386 | lua_unlock(L); |
| 387 | } |
| 388 | |
| 389 | |
| 390 | LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { |