Skip to content

Commit

Permalink
types.TypePrinter: don't waste screen space on empty attribute lists.
Browse files Browse the repository at this point in the history
whitequark committed Feb 27, 2016
1 parent 63e0c7c commit e421b22
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions artiq/compiler/types.py
Original file line number Diff line number Diff line change
@@ -703,12 +703,14 @@ def name(self, typ, depth=0, max_depth=1):
elif isinstance(typ, TInstance):
if typ in self.recurse_guard or depth >= max_depth:
return "<instance {}>".format(typ.name)
else:
elif len(typ.attributes) > 0:
self.recurse_guard.add(typ)
attrs = ",\n\t\t".join(["{}: {}".format(attr, self.name(typ.attributes[attr],
depth + 1))
for attr in typ.attributes])
return "<instance {} {{\n\t\t{}\n\t}}>".format(typ.name, attrs)
else:
return "<instance {} {{}}>".format(typ.name)
elif isinstance(typ, TMono):
if typ.params == {}:
return typ.name
@@ -745,12 +747,14 @@ def name(self, typ, depth=0, max_depth=1):
elif isinstance(typ, (TConstructor, TExceptionConstructor)):
if typ in self.recurse_guard or depth >= max_depth:
return "<constructor {}>".format(typ.name)
else:
elif len(typ.attributes) > 0:
self.recurse_guard.add(typ)
attrs = ", ".join(["{}: {}".format(attr, self.name(typ.attributes[attr],
depth + 1))
for attr in typ.attributes])
return "<constructor {} {{{}}}>".format(typ.name, attrs)
else:
return "<constructor {} {{}}>".format(typ.name)
elif isinstance(typ, TBuiltin):
return "<builtin {}>".format(typ.name)
elif isinstance(typ, TValue):

0 comments on commit e421b22

Please sign in to comment.