MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / lua_arith

Function lua_arith

third-party/lua-5.2.4/src/lapi.c:293–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

luaV_arithFunction · 0.85
luaO_arithFunction · 0.70

Tested by

no test coverage detected