diff python/ir/instruction.py @ 219:1fa3e0050b49

Expanded ad hoc code generator
author Windel Bouwman
date Sat, 06 Jul 2013 12:38:09 +0200
parents 07bfea4c1ed7
children 848c4b15fd0b
line wrap: on
line diff
--- a/python/ir/instruction.py	Fri Jul 05 15:30:22 2013 +0200
+++ b/python/ir/instruction.py	Sat Jul 06 12:38:09 2013 +0200
@@ -156,17 +156,17 @@
 
 # Branching:
 class Branch(Terminator):
-   def __init__(self, target):
+    def __init__(self, target):
       super().__init__()
       assert type(target) is BasicBlock
       self.target = target
-   def __repr__(self):
-      return 'BRANCH {0}'.format(self.target)
-   def getTargets(self):
-      return [self.target]
-   def changeTarget(self, tfrom, tto):
-      if tfrom is self.target:
-         self.target = tto
+    def __repr__(self):
+        return 'BRANCH {0}'.format(self.target)
+    def getTargets(self):
+        return [self.target]
+    def changeTarget(self, tfrom, tto):
+        assert tfrom is self.target
+        self.target = tto
 
 class ConditionalBranch(Terminator):
    def __init__(self, a, cond, b, lab1, lab2):
@@ -187,9 +187,10 @@
    def getTargets(self):
       return [self.lab1, self.lab2]
    def changeTarget(self, tfrom, tto):
+      assert tfrom is self.lab1 or tfrom is self.lab2
       if tfrom is self.lab1:
          self.lab1 = tto
-      if tfrom is self.lab2:
+      elif tfrom is self.lab2:
          self.lab2 = tto
 
 class PhiNode(Instruction):