| 291 | |
| 292 | |
| 293 | LUA_API void lua_arith (lua_State *L, int op) { |
| 294 | StkId o1; /* 1st operand */ |
| 295 | StkId o2; /* 2nd operand */ |
| 296 | lua_lock(L); |
| 297 | if (op != LUA_OPUNM) /* all other operations expect two operands */ |
| 298 | api_checknelems(L, 2); |
| 299 | else { /* for unary minus, add fake 2nd operand */ |
| 300 | api_checknelems(L, 1); |
| 301 | setobjs2s(L, L->top, L->top - 1); |
| 302 | L->top++; |
| 303 | } |
| 304 | o1 = L->top - 2; |
| 305 | o2 = L->top - 1; |
| 306 | if (ttisnumber(o1) && ttisnumber(o2)) { |
| 307 | setnvalue(o1, luaO_arith(op, nvalue(o1), nvalue(o2))); |
| 308 | } |
| 309 | else |
| 310 | luaV_arith(L, o1, o1, o2, cast(TMS, op - LUA_OPADD + TM_ADD)); |
| 311 | L->top--; |
| 312 | lua_unlock(L); |
| 313 | } |
| 314 | |
| 315 | |
| 316 | LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { |
nothing calls this directly
no test coverage detected