Permalink
Browse files

fhdl: fix series of if/elif/else

  • Loading branch information...
1 parent 1a845d4 commit d21e095397ebbe45757cbaf06385878f3670062d @sbourdeauducq sbourdeauducq committed Dec 17, 2011
Showing with 10 additions and 2 deletions.
  1. +10 −2 migen/fhdl/structure.py
View
@@ -161,13 +161,21 @@ def __init__(self, cond, *t):
self.f = StatementList()
def Else(self, *f):
- self.f = StatementList(f)
+ _insert_else(self, StatementList(f))
return self
def Elif(self, cond, *t):
- self.f = StatementList([If(cond, *t)])
+ _insert_else(self, StatementList([If(cond, *t)]))
return self
+def _insert_else(obj, clause):
+ o = obj
+ while o.f.l:
+ assert(len(o.f.l) == 1)
+ assert(isinstance(o.f.l[0], If))
+ o = o.f.l[0]
+ o.f = clause
+
def _sl(x):
if isinstance(x, list):
return StatementList(x)

0 comments on commit d21e095

Please sign in to comment.