| 306 | |
| 307 | |
| 308 | LUA_API void lua_arith (lua_State *L, int op) { |
| 309 | lua_lock(L); |
| 310 | if (op != LUA_OPUNM && op != LUA_OPBNOT) |
| 311 | api_checknelems(L, 2); /* all other operations expect two operands */ |
| 312 | else { /* for unary operations, add fake 2nd operand */ |
| 313 | api_checknelems(L, 1); |
| 314 | setobjs2s(L, L->top, L->top - 1); |
| 315 | api_incr_top(L); |
| 316 | } |
| 317 | /* first operand at top - 2, second at top - 1; result go to top - 2 */ |
| 318 | luaO_arith(L, op, s2v(L->top - 2), s2v(L->top - 1), L->top - 2); |
| 319 | L->top--; /* remove second operand */ |
| 320 | lua_unlock(L); |
| 321 | } |
| 322 | |
| 323 | |
| 324 | LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { |