function luaK.constfolding(T,l,y,S)local s if not T:isnumeral(y)or not T:isnumeral(S)then return false end local i=y.nval local I=S.nval if l=="\079\080\095\065\068\068"then s=T:numadd(i,I)elseif l=="\079\080\095\083\085\066"then s=T:numsub(i,I)elseif l=="\079\080\095\077\085\076"then s=T:nummul(i,I)elseif l=="\079\080\095\068\073\086"then if I==0 then return false end s=T:numdiv(i,I)elseif l=="\079\080\095\077\079\068"then if I==0 then return false end s=T:nummod(i,I)elseif l=="\079\080\095\080\079\087"then s=T:numpow(i,I)elseif l=="\079\080\095\085\078\077"then s=T:numunm(i)elseif l=="\079\080\095\076\069\078"then return false else assert(0)s=0 end if T:numisnan(s)then return false end y.nval=s return true end
------------------------------------------------------------------------
--
-- * used only in luaK:codearith()
------------------------------------------------------------------------
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
