MCPcopy Create free account
hub / github.com/defold/defold / Arith

Function Arith

engine/lua/src/lua/lvm.c:313–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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