annotate python/ir/value.py @ 157:8f3924b6076e

Added some code generator things
author Windel Bouwman
date Sun, 03 Mar 2013 18:14:35 +0100
parents b28a11c01dbe
children 9683a4cd848f
rev   line source
70
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
1
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
2 class Value:
110
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
3 def __init__(self, vty=None):
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
4 self.valueType = vty
70
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
5 self.name = None
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
6 def getContext(self):
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
7 return self.valueType.context
104
ed230e947dc6 Added hexviewer
windel
parents: 95
diff changeset
8 def dump(self):
ed230e947dc6 Added hexviewer
windel
parents: 95
diff changeset
9 print(self)
110
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
10 def getName(self):
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
11 return self.name
70
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
12 def setName(self, name):
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
13 if not self.name and not name:
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
14 return
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
15 self.name = name
110
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
16 Name = property(getName, setName)
70
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
17
110
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
18 class Constant(Value):
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
19 def __init__(self, value, vty):
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
20 super().__init__(vty)
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
21 self.value = value
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
22 print('new constant value: ', value)
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
23