Mercurial > lcfOS
comparison python/ppci/c3/astnodes.py @ 354:5477e499b039
Added some sort of string functionality
author | Windel Bouwman |
---|---|
date | Thu, 13 Mar 2014 18:59:06 +0100 |
parents | d1ecc493384e |
children | 2ec730e45ea1 |
comparison
equal
deleted
inserted
replaced
353:b8ad45b3a573 | 354:5477e499b039 |
---|---|
123 | 123 |
124 def __repr__(self): | 124 def __repr__(self): |
125 return 'STRUCT' | 125 return 'STRUCT' |
126 | 126 |
127 | 127 |
128 class ArrayType(Type): | |
129 """ Array type """ | |
130 def __init__(self, element_type, size): | |
131 self.element_type = element_type | |
132 self.size = size | |
133 | |
134 def __repr__(self): | |
135 return 'ARRAY {}'.format(self.size) | |
136 | |
137 | |
128 class DefinedType(NamedType): | 138 class DefinedType(NamedType): |
129 """ A named type indicating another type """ | 139 """ A named type indicating another type """ |
130 def __init__(self, name, typ, loc): | 140 def __init__(self, name, typ, loc): |
131 assert isinstance(name, str) | 141 assert isinstance(name, str) |
132 super().__init__(name) | 142 super().__init__(name) |
221 self.base = base | 231 self.base = base |
222 self.field = field | 232 self.field = field |
223 | 233 |
224 def __repr__(self): | 234 def __repr__(self): |
225 return 'MEMBER {}.{}'.format(self.base, self.field) | 235 return 'MEMBER {}.{}'.format(self.base, self.field) |
236 | |
237 | |
238 class Index(Expression): | |
239 """ Index something, for example an array """ | |
240 def __init__(self, base, i, loc): | |
241 super().__init__(loc) | |
242 self.base = base | |
243 self.i = i | |
244 | |
245 def __repr__(self): | |
246 return 'Index {}'.format(self.i) | |
226 | 247 |
227 | 248 |
228 class Unop(Expression): | 249 class Unop(Expression): |
229 """ Operation on one operand """ | 250 """ Operation on one operand """ |
230 def __init__(self, op, a, loc): | 251 def __init__(self, op, a, loc): |