MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / Arith

Function Arith

lua/lvm.c:359–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357
358
359static void Arith (lua_State *L, StkId ra, const TValue *rb,
360 const TValue *rc, TMS op) {
361 TValue tempb, tempc;
362 const TValue *b, *c;
363 if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
364 (c = luaV_tonumber(rc, &tempc)) != NULL) {
365 lua_Number nb = nvalue(b), nc = nvalue(c);
366 switch (op) {
367 case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
368 case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
369 case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
370 case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
371 case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
372 case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
373 case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
374 default: lua_assert(0); break;
375 }
376 }
377 else if (!call_binTM(L, rb, rc, ra, op))
378 luaG_aritherror(L, rb, rc);
379}
380
381
382

Callers 1

luaV_executeFunction · 0.85

Calls 3

luaV_tonumberFunction · 0.85
call_binTMFunction · 0.85
luaG_aritherrorFunction · 0.85

Tested by

no test coverage detected