/* Try to "constant-fold" an operation; return 1 iff successful. (In this case, 'e1' has the final result.)  */
static int constfolding(FuncState *fs, int op, expdesc *e1, const expdesc *e2)
/* Try to "constant-fold" an operation; return 1 iff successful. (In this case, 'e1' has the final result.)  */
static int constfolding(FuncState *fs, int op, expdesc *e1, const expdesc *e2)
{
  TValue v1, v2, res;
  if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2))
    return 0;
  luaO_arith(fs->ls->L, op, &v1, &v2, &res);
  if (ttisinteger(&res)) {
    e1->k = VKINT;
    e1->u.ival = ivalue(&res);
  }
  else {
    lua_Number n = fltvalue(&res);
    if (luai_numisnan(n) || n == 0)
      return 0;
    e1->k = VKFLT;
    e1->u.nval = n;
  }
  return 1;
}