Mercurial > lcfOS
comparison python/c3/astnodes.py @ 227:82dfe6a32717
Fixed tests
author | Windel Bouwman |
---|---|
date | Fri, 12 Jul 2013 17:42:39 +0200 |
parents | 240111e0456f |
children | 7f18ed9b6b7e |
comparison
equal
deleted
inserted
replaced
226:240111e0456f | 227:82dfe6a32717 |
---|---|
62 assert isinstance(ptype, Type) or isinstance(ptype, Designator) | 62 assert isinstance(ptype, Type) or isinstance(ptype, Designator) |
63 self.ptype = ptype | 63 self.ptype = ptype |
64 def __repr__(self): | 64 def __repr__(self): |
65 return '({}*)'.format(self.ptype) | 65 return '({}*)'.format(self.ptype) |
66 | 66 |
67 class StructField: | |
68 def __init__(self, name, typ): | |
69 self.name = name | |
70 self.typ = typ | |
71 | |
67 class StructureType(Type): | 72 class StructureType(Type): |
68 def __init__(self, mems): | 73 def __init__(self, mems): |
69 self.mems = mems | 74 self.mems = mems |
70 for ft, fn in mems: | 75 for mem in mems: |
71 assert type(fn) is str | 76 assert type(mem) is StructField |
77 assert type(mem.name) is str | |
72 def hasField(self, name): | 78 def hasField(self, name): |
73 for ft, fn in self.mems: | 79 for mem in self.mems: |
74 if name == fn: | 80 if name == mem.name: |
75 return True | 81 return True |
76 return False | 82 return False |
77 def fieldType(self, name): | 83 def fieldType(self, name): |
78 for ft, fn in self.mems: | 84 for mem in self.mems: |
79 if name == fn: | 85 if name == mem.name: |
80 return ft | 86 return mem.typ |
81 raise Exception() | 87 raise Exception() |
82 | 88 |
83 | 89 |
84 class DefinedType(Type): | 90 class DefinedType(Type): |
85 def __init__(self, name, typ, loc): | 91 def __init__(self, name, typ, loc): |