MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / Arith

Function Arith

other_src/lua/src/lvm.cpp:319–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

luaV_executeFunction · 0.70

Calls 3

luaV_tonumberFunction · 0.70
call_binTMFunction · 0.70
luaG_aritherrorFunction · 0.70

Tested by

no test coverage detected