comparison python/c3/astnodes.py @ 226:240111e0456f

Work on named types
author Windel Bouwman
date Fri, 12 Jul 2013 17:25:31 +0200
parents 1c7364bd74c7
children 82dfe6a32717
comparison
equal deleted inserted replaced
225:1c7364bd74c7 226:240111e0456f
65 return '({}*)'.format(self.ptype) 65 return '({}*)'.format(self.ptype)
66 66
67 class StructureType(Type): 67 class StructureType(Type):
68 def __init__(self, mems): 68 def __init__(self, mems):
69 self.mems = mems 69 self.mems = mems
70 for ft, fn in mems:
71 assert type(fn) is str
70 def hasField(self, name): 72 def hasField(self, name):
71 for fn, ft in self.mems: 73 for ft, fn in self.mems:
72 if name == fn: 74 if name == fn:
73 return True 75 return True
74 return False 76 return False
75 def fieldType(self, name): 77 def fieldType(self, name):
76 for fn, ft in self.mems: 78 for ft, fn in self.mems:
77 if name == fn: 79 if name == fn:
78 return ft 80 return ft
79 raise Exception() 81 raise Exception()
80 82
81 83