forked from M-Labs/artiq
1
0
Fork 0

types.TypePrinter: don't waste screen space on empty attribute lists.

This commit is contained in:
whitequark 2016-02-27 13:29:47 +00:00
parent 63e0c7c07c
commit e421b22953
1 changed files with 6 additions and 2 deletions

View File

@ -703,12 +703,14 @@ class TypePrinter(object):
elif isinstance(typ, TInstance): elif isinstance(typ, TInstance):
if typ in self.recurse_guard or depth >= max_depth: if typ in self.recurse_guard or depth >= max_depth:
return "<instance {}>".format(typ.name) return "<instance {}>".format(typ.name)
else: elif len(typ.attributes) > 0:
self.recurse_guard.add(typ) self.recurse_guard.add(typ)
attrs = ",\n\t\t".join(["{}: {}".format(attr, self.name(typ.attributes[attr], attrs = ",\n\t\t".join(["{}: {}".format(attr, self.name(typ.attributes[attr],
depth + 1)) depth + 1))
for attr in typ.attributes]) for attr in typ.attributes])
return "<instance {} {{\n\t\t{}\n\t}}>".format(typ.name, attrs) return "<instance {} {{\n\t\t{}\n\t}}>".format(typ.name, attrs)
else:
return "<instance {} {{}}>".format(typ.name)
elif isinstance(typ, TMono): elif isinstance(typ, TMono):
if typ.params == {}: if typ.params == {}:
return typ.name return typ.name
@ -745,12 +747,14 @@ class TypePrinter(object):
elif isinstance(typ, (TConstructor, TExceptionConstructor)): elif isinstance(typ, (TConstructor, TExceptionConstructor)):
if typ in self.recurse_guard or depth >= max_depth: if typ in self.recurse_guard or depth >= max_depth:
return "<constructor {}>".format(typ.name) return "<constructor {}>".format(typ.name)
else: elif len(typ.attributes) > 0:
self.recurse_guard.add(typ) self.recurse_guard.add(typ)
attrs = ", ".join(["{}: {}".format(attr, self.name(typ.attributes[attr], attrs = ", ".join(["{}: {}".format(attr, self.name(typ.attributes[attr],
depth + 1)) depth + 1))
for attr in typ.attributes]) for attr in typ.attributes])
return "<constructor {} {{{}}}>".format(typ.name, attrs) return "<constructor {} {{{}}}>".format(typ.name, attrs)
else:
return "<constructor {} {{}}>".format(typ.name)
elif isinstance(typ, TBuiltin): elif isinstance(typ, TBuiltin):
return "<builtin {}>".format(typ.name) return "<builtin {}>".format(typ.name)
elif isinstance(typ, TValue): elif isinstance(typ, TValue):