172
|
1 from .basicblock import BasicBlock
|
|
2
|
|
3 class Function:
|
230
|
4 def __init__(self, name):
|
172
|
5 self.name = name
|
|
6 self.bbs = []
|
|
7 self.entry = None
|
205
|
8
|
230
|
9 def __repr__(self):
|
|
10 return 'Function {0}'.format(self.name)
|
205
|
11
|
230
|
12 def addBB(self, bb):
|
|
13 self.bbs.append(bb)
|
|
14 bb.parent = self
|
|
15 addBasicBlock = addBB
|
205
|
16
|
230
|
17 def removeBasicBlock(self, bb):
|
|
18 self.bbs.remove(bb)
|
|
19 bb.parent = None
|
|
20
|
|
21 def getBBs(self):
|
|
22 return self.bbs
|
205
|
23
|
230
|
24 def findBasicBlock(self, name):
|
|
25 for bb in self.bbs:
|
|
26 if bb.name == name:
|
|
27 return bb
|
|
28 raise KeyError(name)
|
|
29
|
|
30 BasicBlocks = property(getBBs)
|
172
|
31
|
239
|
32 def check(self):
|
|
33 for bb in self.BasicBlocks:
|
|
34 bb.check()
|