diff python/ir/basicblock.py @ 174:3eb06f5fb987

Added memory alloc for locals
author Windel Bouwman
date Fri, 19 Apr 2013 19:22:52 +0200
parents c1d2b6b9f9a7
children 460db5669efa
line wrap: on
line diff
--- a/python/ir/basicblock.py	Fri Apr 19 12:42:21 2013 +0200
+++ b/python/ir/basicblock.py	Fri Apr 19 19:22:52 2013 +0200
@@ -1,6 +1,6 @@
 
 class BasicBlock:
-   # Uninterrupted sequence of instructions.
+   """ Uninterrupted sequence of instructions. """
    def __init__(self, name):
       self.name = name
       self.instructions = []
@@ -13,6 +13,7 @@
    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):
@@ -20,10 +21,16 @@
       self.instructions.remove(i)
    def getInstructions(self):
       return self.instructions
-   Instructions = property(getInstructions)
+   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)
    def getLastIns(self):
       return self.instructions[-1]
-   LastIns = property(getLastIns)
+   LastInstruction = property(getLastIns)
    @property
    def Empty(self):
       return len(self.instructions) == 0
@@ -33,8 +40,11 @@
    FirstIns = FirstInstruction
    def getSuccessors(self):
       if not self.Empty:
-         i = self.LastIns
+         i = self.LastInstruction
          return i.Targets
       return []
    Successors = property(getSuccessors)
+   def getPredecessors(self):
+      return []
+   Predecessors = property(getPredecessors)