annotate python/ir/function.py @ 221:848c4b15fd0b

pointers
author Windel Bouwman
date Mon, 08 Jul 2013 22:21:44 +0200
parents d77cb5962cc5
children 88a1e0baef65
rev   line source
172
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
1 from .basicblock import BasicBlock
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
2
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
3 class Function:
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
4 def __init__(self, name):
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
5 self.name = name
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
6 self.bbs = []
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
7 self.entry = None
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 177
diff changeset
8
172
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
9 def __repr__(self):
173
c1d2b6b9f9a7 Rework into passes
Windel Bouwman
parents: 172
diff changeset
10 return 'Function {0}'.format(self.name)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 177
diff changeset
11
172
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
12 def addBB(self, bb):
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
13 self.bbs.append(bb)
177
460db5669efa Added clean pass for IR
Windel Bouwman
parents: 173
diff changeset
14 bb.parent = self
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 177
diff changeset
15 addBasicBlock = addBB
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 177
diff changeset
16
177
460db5669efa Added clean pass for IR
Windel Bouwman
parents: 173
diff changeset
17 def removeBasicBlock(self, bb):
460db5669efa Added clean pass for IR
Windel Bouwman
parents: 173
diff changeset
18 self.bbs.remove(bb)
460db5669efa Added clean pass for IR
Windel Bouwman
parents: 173
diff changeset
19 bb.parent = None
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 177
diff changeset
20
172
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
21 def getBBs(self):
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
22 return self.bbs
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
23 BasicBlocks = property(getBBs)
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
24
5a7d37d615ee Added function to IR
Windel Bouwman
parents:
diff changeset
25