| 331 | |
| 332 | |
| 333 | LUA_API void lua_arith (lua_State *L, int op) { |
| 334 | lua_lock(L); |
| 335 | if (op != LUA_OPUNM && op != LUA_OPBNOT) |
| 336 | api_checkpop(L, 2); /* all other operations expect two operands */ |
| 337 | else { /* for unary operations, add fake 2nd operand */ |
| 338 | api_checkpop(L, 1); |
| 339 | setobjs2s(L, L->top.p, L->top.p - 1); |
| 340 | api_incr_top(L); |
| 341 | } |
| 342 | /* first operand at top - 2, second at top - 1; result go to top - 2 */ |
| 343 | luaO_arith(L, op, s2v(L->top.p - 2), s2v(L->top.p - 1), L->top.p - 2); |
| 344 | L->top.p--; /* pop second operand */ |
| 345 | lua_unlock(L); |
| 346 | } |
| 347 | |
| 348 | |
| 349 | LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { |