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

Expanded ad hoc code generator
author Windel Bouwman
date Sat, 06 Jul 2013 12:38:09 +0200
parents d77cb5962cc5
children 63bb40758066
line wrap: on
line diff
--- a/python/ir/basicblock.py	Fri Jul 05 15:30:22 2013 +0200
+++ b/python/ir/basicblock.py	Sat Jul 06 12:38:09 2013 +0200
@@ -1,60 +1,61 @@
 
 class BasicBlock:
-   """ Uninterrupted sequence of instructions. """
-   def __init__(self, name):
+    """ Uninterrupted sequence of instructions. """
+    def __init__(self, name):
       self.name = name
       self.instructions = []
-   def __repr__(self):
+    def __repr__(self):
       return 'BasicBlock {0}'.format(self.name)
-   def addInstruction(self, i):
+    def addInstruction(self, i):
       i.parent = self
       self.instructions.append(i)
-   addIns = addInstruction
+    addIns = addInstruction
 
-   def replaceInstruction(self, i1, i2):
+    def replaceInstruction(self, i1, i2):
       idx = self.instructions.index(i1)
       i1.parent = None
       i1.delete()
       i2.parent = self
       self.instructions[idx] = i2
 
-   def removeInstruction(self, i):
+    def removeInstruction(self, i):
       i.parent = None
       self.instructions.remove(i)
 
-   def getInstructions(self):
+    def getInstructions(self):
         return self.instructions
 
-   def setInstructions(self, ins):
+    def setInstructions(self, ins):
       for i in self.instructions:
          i.parent = None
       self.instructions = ins
       for i in self.instructions:
          i.parent = self
-   Instructions = property(getInstructions, setInstructions)
+    Instructions = property(getInstructions, setInstructions)
 
-   def getLastIns(self):
+    def getLastIns(self):
       return self.instructions[-1]
-   LastInstruction = property(getLastIns)
-   @property
-   def Empty(self):
+    LastInstruction = property(getLastIns)
+    @property
+    def Empty(self):
       return len(self.instructions) == 0
-   @property
-   def FirstInstruction(self):
+    @property
+    def FirstInstruction(self):
       return self.instructions[0]
-   FirstIns = FirstInstruction
-   def getSuccessors(self):
+    FirstIns = FirstInstruction
+
+    def getSuccessors(self):
       if not self.Empty:
          i = self.LastInstruction
-         print(i)
          return i.Targets
       return []
-   Successors = property(getSuccessors)
-   def getPredecessors(self):
+    Successors = property(getSuccessors)
+
+    def getPredecessors(self):
       preds = []
       for bb in self.parent.BasicBlocks:
          if self in bb.Successors:
             preds.append(bb)
       return preds
-   Predecessors = property(getPredecessors)
+    Predecessors = property(getPredecessors)