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