forked from M-Labs/artiq
compiler.iodelay: fold MUToS and SToMU.
This commit is contained in:
parent
82b470891f
commit
5cd12ffd28
|
@ -106,6 +106,12 @@ class MUToS(Conv):
|
|||
def eval(self, env):
|
||||
return self.operand.eval(env) * self.ref_period
|
||||
|
||||
def fold(self, vars=None):
|
||||
if isinstance(self.operand, Const):
|
||||
return Const(self.operand.value * self.ref_period)
|
||||
else:
|
||||
return super().fold(vars)
|
||||
|
||||
class SToMU(Conv):
|
||||
def __str__(self):
|
||||
return "s->mu({})".format(self.operand)
|
||||
|
@ -113,6 +119,12 @@ class SToMU(Conv):
|
|||
def eval(self, env):
|
||||
return self.operand.eval(env) / self.ref_period
|
||||
|
||||
def fold(self, vars=None):
|
||||
if isinstance(self.operand, Const):
|
||||
return Const(self.operand.value / self.ref_period)
|
||||
else:
|
||||
return super().fold(vars)
|
||||
|
||||
class BinOp(Expr):
|
||||
def __init__(self, lhs, rhs):
|
||||
self.lhs, self.rhs = lhs, rhs
|
||||
|
|
Loading…
Reference in New Issue