annotate python/ir/value.py @ 160:10330be89bc2

Started from scratch with code edit
author Windel Bouwman
date Sat, 09 Mar 2013 11:56:48 +0100
parents 9683a4cd848f
children
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)
158
9683a4cd848f Added some functions for code generation
Windel Bouwman
parents: 155
diff changeset
17 def __repr__(self):
9683a4cd848f Added some functions for code generation
Windel Bouwman
parents: 155
diff changeset
18 return 'VALUE {0}'.format(self.name)
70
35286e8abd03 Added some llvm classes
windel
parents:
diff changeset
19
110
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
20 class Constant(Value):
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
21 def __init__(self, value, vty):
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
22 super().__init__(vty)
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
23 self.value = value
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
24 print('new constant value: ', value)
9e552d34bd60 Work on compiler
Windel Bouwman
parents: 104
diff changeset
25