alway_comb nested if support
[sv2nmigen.git] / absyn.py
index 413e51301580f81b58f54dd12e3e1b0dc6ebbc2b..2931be810ea3533f828bcd85c9c4e576bf00000b 100644 (file)
--- a/absyn.py
+++ b/absyn.py
@@ -54,6 +54,13 @@ class CondStatement:
         self.elsepart = elsepart
 
 
+def makeBlock(x):
+    if(type(x) == Assignment):
+        return [x]
+    else:
+        return x.statements
+
+
 class Absyn:
     def __init__(self, outputfn):
         self.outputfn = outputfn
@@ -146,7 +153,7 @@ class Absyn:
         stmts.children.append(Leaf(token.STRING, "):"))
         stmts.children.append(self.nl())
 
-        for c1 in c.ifpart.statements:
+        for c1 in makeBlock(c.ifpart):
             if(type(c1) == Assignment):
                 self.do_assign(c1, stmts, indent+1)
             else:
@@ -157,7 +164,7 @@ class Absyn:
             stmts.children.append(Leaf(token.STRING, "with m.Else():"))
             stmts.children.append(self.nl())
 
-            for c1 in c.elsepart.statements:
+            for c1 in makeBlock(c.elsepart):
                 if(type(c1) == Assignment):
                     self.do_assign(c1, stmts, indent+1)
                 else: