| 315 | |
| 316 | |
| 317 | static void Arith (lua_State *L, StkId ra, const TValue *rb, |
| 318 | const TValue *rc, TMS op) { |
| 319 | TValue tempb, tempc; |
| 320 | const TValue *b, *c; |
| 321 | if ((b = luaV_tonumber(rb, &tempb)) != NULL && |
| 322 | (c = luaV_tonumber(rc, &tempc)) != NULL) { |
| 323 | lua_Number nb = nvalue(b), nc = nvalue(c); |
| 324 | switch (op) { |
| 325 | case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; |
| 326 | case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; |
| 327 | case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; |
| 328 | case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; |
| 329 | case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; |
| 330 | case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; |
| 331 | case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; |
| 332 | default: lua_assert(0); break; |
| 333 | } |
| 334 | } |
| 335 | else if (!call_binTM(L, rb, rc, ra, op)) |
| 336 | luaG_aritherror(L, rb, rc); |
| 337 | } |
| 338 | |
| 339 | |
| 340 |
no test coverage detected