Add more cases for prettyprinting types.
This commit is contained in:
parent
05be04891b
commit
a7b3db8c1d
21
ll.py
21
ll.py
|
@ -13,6 +13,20 @@ class SimpleType(Enum):
|
|||
I32 = 4
|
||||
I64 = 5
|
||||
|
||||
def __repr__(self):
|
||||
if self == SimpleType.Void:
|
||||
return 'void'
|
||||
elif self == SimpleType.I1:
|
||||
return 'i1'
|
||||
elif self == SimpleType.I8:
|
||||
return 'i8'
|
||||
elif self == SimpleType.I32:
|
||||
return 'i32'
|
||||
elif self == SimpleType.I64:
|
||||
return 'i64'
|
||||
else:
|
||||
return str(self)
|
||||
|
||||
|
||||
Program = namedtuple('Program', ['tdecls', 'gdecls', 'fdecls'])
|
||||
|
||||
|
@ -57,12 +71,15 @@ Id = namedtuple('Id', ['val'])
|
|||
|
||||
|
||||
def ty2s(ty):
|
||||
if ty == SimpleType.I64:
|
||||
return 'i64'
|
||||
if isinstance(ty, SimpleType):
|
||||
return repr(ty)
|
||||
elif isinstance(ty, PointerType):
|
||||
return ty2s(ty.inner_ty) + '*'
|
||||
else:
|
||||
# TODO
|
||||
print('Unknown type: {}'
|
||||
.format(ty))
|
||||
return str(ty)
|
||||
|
||||
|
||||
def oper2s(operand):
|
||||
|
|
Loading…
Reference in New Issue
Block a user