compiler.iodelay: subtraction certainly shouldn't be commutative.

This commit is contained in:
whitequark 2015-11-20 22:15:03 +08:00
parent cc623c13b4
commit cb9e7d15bf

View File

@ -158,18 +158,23 @@ class Add(BinOpFixpoint):
_op = lambda a, b: a + b
_fixpoint = 0
class Sub(BinOpFixpoint):
_priority = 2
_symbol = "-"
_op = lambda a, b: a - b
_fixpoint = 0
class Mul(BinOpFixpoint):
_priority = 1
_symbol = "*"
_op = lambda a, b: a * b
_fixpoint = 1
class Sub(BinOp):
_priority = 2
_symbol = "-"
_op = lambda a, b: a - b
def _fold_binop(self, lhs, rhs):
if isinstance(rhs, Const) and rhs.value == 0:
return lhs
else:
return super()._fold_binop(lhs, rhs)
class Div(BinOp):
def _fold_binop(self, lhs, rhs):
if isinstance(rhs, Const) and rhs.value == 1: