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