function luaK.constfolding(h,f,S,v)local l if not h:isnumeral(S)or not h:isnumeral(v)then return false end local u=S.nval local N=v.nval if f=="\079\080\095\065\068\068"then l=h:numadd(u,N)elseif f=="\079\080\095\083\085\066"then l=h:numsub(u,N)elseif f=="\079\080\095\077\085\076"then l=h:nummul(u,N)elseif f=="\079\080\095\068\073\086"then if N==0 then return false end l=h:numdiv(u,N)elseif f=="\079\080\095\077\079\068"then if N==0 then return false end l=h:nummod(u,N)elseif f=="\079\080\095\080\079\087"then l=h:numpow(u,N)elseif f=="\079\080\095\085\078\077"then l=h:numunm(u)elseif f=="\079\080\095\076\069\078"then return false else assert(0)l=0 end if h:numisnan(l)then return false end S.nval=l return true end

function luaK:constfolding(op, e1, e2)
  local r
  if not self:isnumeral(e1) or not self:isnumeral(e2) then return false end
  local v1 = e1.nval
  local v2 = e2.nval
  if op == "OP_ADD" then
    r = self:numadd(v1, v2)
  elseif op == "OP_SUB" then
    r = self:numsub(v1, v2)
  elseif op == "OP_MUL" then
    r = self:nummul(v1, v2)
  elseif op == "OP_DIV" then
    if v2 == 0 then return false end  -- do not attempt to divide by 0
    r = self:numdiv(v1, v2)
  elseif op == "OP_MOD" then
    if v2 == 0 then return false end  -- do not attempt to divide by 0
    r = self:nummod(v1, v2)
  elseif op == "OP_POW" then
    r = self:numpow(v1, v2)
  elseif op == "OP_UNM" then
    r = self:numunm(v1)
  elseif op == "OP_LEN" then
    return false  -- no constant folding for 'len'
  else
    assert(0)
    r = 0
  end
  if self:numisnan(r) then return false end  -- do not attempt to produce NaN
  e1.nval = r
  return true
end
