viruscamp / luadec

Lua Decompiler for lua 5.1 , 5.2 and 5.3
1.14k stars 343 forks source link

remove operand swap when processing EQ LT LE #28

Open viruscamp opened 10 years ago

viruscamp commented 10 years ago

test case

function lt_const(a,b,c)
    b = a>3
    b = 3<a
    b = not (a<=3)
    b = not (3>=a)
end

function lt_if(a,b,c)
    if a>3 then
        b()
    end
    if not (a<=3) then
        c()
    end
end

function eq_const(a,b,c)
    b = a==3
    b = 3==a
end
viruscamp commented 9 years ago

bug, calucate order changed

function lt_function(a,b,c)
    a = b()>c()
    a = c()<b()
    a = not (b()<=c())
    a = not (c()>=b())
end