Mercurial > lcfOS
diff python/ir/function.py @ 268:5ec7580976d9
Op naar tree-IR
author | Windel Bouwman |
---|---|
date | Wed, 14 Aug 2013 20:12:40 +0200 |
parents | 225f444019b1 |
children | 5f8c04a8d26b |
line wrap: on
line diff
--- a/python/ir/function.py Mon Aug 12 20:14:47 2013 +0200 +++ b/python/ir/function.py Wed Aug 14 20:12:40 2013 +0200 @@ -1,10 +1,9 @@ -from .basicblock import BasicBlock +from .basicblock import Block class Function: def __init__(self, name): self.name = name - self.bbs = [] - self.entry = None + self.entry = Block('entry') def __repr__(self): return 'Function {0}'.format(self.name) @@ -19,7 +18,15 @@ bb.parent = None def getBBs(self): - return self.bbs + bbs = [self.entry] + worklist = [self.entry] + while worklist: + b = worklist.pop() + for sb in b.Successors: + if sb not in bbs: + bbs.append(sb) + worklist.append(sb) + return bbs def findBasicBlock(self, name): for bb in self.bbs: