Advertisement
tinyevil

Untitled

Feb 18th, 2019
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. LUA_API void  lua_arith (lua_State *L, int op) {
  2.   StkId o1;  /* 1st operand */
  3.   StkId o2;  /* 2nd operand */
  4.   lua_lock(L);
  5.   if (op != LUA_OPUNM) /* all other operations expect two operands */
  6.     api_checknelems(L, 2);
  7.   else {  /* for unary minus, add fake 2nd operand */
  8.     api_checknelems(L, 1);
  9.     setobjs2s(L, L->top, L->top - 1);
  10.     L->top++;
  11.   }
  12.   o1 = L->top - 2;
  13.   o2 = L->top - 1;
  14.   if (ttisnumber(o1) && ttisnumber(o2)) {
  15.     changenvalue(o1, luaO_arith(op, nvalue(o1), nvalue(o2)));
  16.   }
  17.   else
  18.     luaV_arith(L, o1, o1, o2, cast(TMS, op - LUA_OPADD + TM_ADD));
  19.   L->top--;
  20.   lua_unlock(L);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement