[cfe-commits] r114867 - in /cfe/trunk/utils/ABITest: ABITestGen.py TypeGen.py
Daniel Dunbar
daniel at zuster.org
Mon Sep 27 13:13:24 PDT 2010
Author: ddunbar
Date: Mon Sep 27 15:13:24 2010
New Revision: 114867
URL: http://llvm.org/viewvc/llvm-project?rev=114867&view=rev
Log:
utils/ABITest: Factor out type naming code slightly.
Modified:
cfe/trunk/utils/ABITest/ABITestGen.py
cfe/trunk/utils/ABITest/TypeGen.py
Modified: cfe/trunk/utils/ABITest/ABITestGen.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/ABITestGen.py?rev=114867&r1=114866&r2=114867&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/ABITestGen.py (original)
+++ cfe/trunk/utils/ABITest/ABITestGen.py Mon Sep 27 15:13:24 2010
@@ -23,6 +23,7 @@
self.testValues = {}
self.testReturnValues = {}
self.layoutTests = []
+ self.declarations = set()
if info:
for f in (self.output,self.outputHeader,self.outputTests,self.outputDriver):
@@ -64,21 +65,25 @@
print >>self.outputDriver, ' return 0;'
print >>self.outputDriver, '}'
+ def addDeclaration(self, decl):
+ if decl in self.declarations:
+ return False
+
+ self.declarations.add(decl)
+ if self.outputHeader:
+ print >>self.outputHeader, decl
+ else:
+ print >>self.output, decl
+ if self.outputTests:
+ print >>self.outputTests, decl
+ return True
+
def getTypeName(self, T):
- if isinstance(T,BuiltinType):
- return T.name
name = self.types.get(T)
if name is None:
- name = 'T%d'%(len(self.types),)
# Reserve slot
self.types[T] = None
- if self.outputHeader:
- print >>self.outputHeader,T.getTypedefDef(name, self)
- else:
- print >>self.output,T.getTypedefDef(name, self)
- if self.outputTests:
- print >>self.outputTests,T.getTypedefDef(name, self)
- self.types[T] = name
+ self.types[T] = name = T.getTypeName(self)
return name
def writeLayoutTest(self, i, ty):
Modified: cfe/trunk/utils/ABITest/TypeGen.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/TypeGen.py?rev=114867&r1=114866&r2=114867&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/TypeGen.py (original)
+++ cfe/trunk/utils/ABITest/TypeGen.py Mon Sep 27 15:13:24 2010
@@ -24,6 +24,12 @@
def isPaddingBitField(self):
return False
+ def getTypeName(self, printer):
+ name = 'T%d' % len(printer.types)
+ typedef = self.getTypedefDef(name, printer)
+ printer.addDeclaration(typedef)
+ return name
+
class BuiltinType(Type):
def __init__(self, name, size, bitFieldSize=None):
self.name = name
@@ -40,6 +46,9 @@
assert self.isBitField()
return self.bitFieldSize
+ def getTypeName(self, printer):
+ return self.name
+
def sizeof(self):
return self.size
More information about the cfe-commits
mailing list