|
|
|
@ -12,13 +12,18 @@ class ArrayType(Type): |
|
|
|
|
if isinstance(length, int): |
|
|
|
|
length = Literal(length) |
|
|
|
|
assert isinstance(length, Expression) |
|
|
|
|
if not isinstance(length, Literal): |
|
|
|
|
cf = ConstantFolding(length) |
|
|
|
|
length = cf.result() |
|
|
|
|
super(ArrayType, self).__init__() |
|
|
|
|
self._type = t |
|
|
|
|
self._length = length |
|
|
|
|
|
|
|
|
|
if length: |
|
|
|
|
if not isinstance(length, Literal): |
|
|
|
|
cf = ConstantFolding(length) |
|
|
|
|
length = cf.result() |
|
|
|
|
self._length_value = length |
|
|
|
|
else: |
|
|
|
|
self._length_value = None |
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
def type(self): |
|
|
|
|
return self._type |
|
|
|
@ -29,9 +34,7 @@ class ArrayType(Type): |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
if self._length: |
|
|
|
|
if isinstance(self._length.value, Variable) and self._length.value.is_constant: |
|
|
|
|
return str(self._type)+'[{}]'.format(str(self._length.value.expression)) |
|
|
|
|
return str(self._type)+'[{}]'.format(str(self._length)) |
|
|
|
|
return str(self._type)+'[{}]'.format(str(self._length_value)) |
|
|
|
|
return str(self._type)+'[]' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|