MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lua_arith

Function lua_arith

freebsd/contrib/openzfs/module/lua/lapi.c:290–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

luaO_arithFunction · 0.85
luaV_arithFunction · 0.85

Tested by

no test coverage detected