annotate python/ir/basicblock.py @ 171:3eb9b9e2958d

Improved IR code
author Windel Bouwman
date Wed, 03 Apr 2013 22:20:20 +0200
parents
children c1d2b6b9f9a7
rev   line source
171
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
1
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
2 class BasicBlock:
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
3 # Uninterrupted sequence of instructions.
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
4 def __init__(self, name):
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
5 self.name = name
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
6 self.instructions = []
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
7 def __repr__(self):
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
8 return 'BB {0}'.format(self.name)
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
9 def addIns(self, i):
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
10 self.instructions.append(i)
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
11 def getInstructions(self):
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
12 return self.instructions
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
13 Instructions = property(getInstructions)
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
14 def getLastIns(self):
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
15 return self.instructions[-1]
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
16 LastIns = property(getLastIns)
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
17 @property
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
18 def Empty(self):
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
19 return len(self.instructions) == 0
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
20 @property
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
21 def FirstIns(self):
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
22 return self.instructions[0]
3eb9b9e2958d Improved IR code
Windel Bouwman
parents:
diff changeset
23