Skip to content

Commit

Permalink
Use pretty-printer in Type::toChars()
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Feb 4, 2015
1 parent 16a0faa commit 2da20e0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 47 deletions.
38 changes: 1 addition & 37 deletions src/mtype.c
Expand Up @@ -1492,6 +1492,7 @@ char *Type::toChars()
OutBuffer buf;
buf.reserve(16);
HdrGenState hgs;
hgs.fullQual = (ty == Tclass && !mod);

::toCBuffer(this, &buf, NULL, &hgs);
return buf.extractString();
Expand Down Expand Up @@ -2874,11 +2875,6 @@ Type *TypeBasic::syntaxCopy()
return this;
}

char *TypeBasic::toChars()
{
return Type::toChars();
}

d_uns64 TypeBasic::size(Loc loc)
{ unsigned size;

Expand Down Expand Up @@ -3519,11 +3515,6 @@ bool TypeVector::checkBoolean()
return false;
}

char *TypeVector::toChars()
{
return Type::toChars();
}

d_uns64 TypeVector::size(Loc loc)
{
return basetype->size();
Expand Down Expand Up @@ -7139,13 +7130,6 @@ const char *TypeEnum::kind()
return "enum";
}

char *TypeEnum::toChars()
{
if (mod)
return Type::toChars();
return sym->toChars();
}

Type *TypeEnum::syntaxCopy()
{
return this;
Expand Down Expand Up @@ -7378,19 +7362,6 @@ const char *TypeStruct::kind()
return "struct";
}

char *TypeStruct::toChars()
{
//printf("sym.parent: %s, deco = %s\n", sym->parent->toChars(), deco);
if (mod)
return Type::toChars();
TemplateInstance *ti = sym->parent->isTemplateInstance();
if (ti && ti->aliasdecl == sym)
{
return ti->toChars();
}
return sym->toChars();
}

Type *TypeStruct::syntaxCopy()
{
return this;
Expand Down Expand Up @@ -7943,13 +7914,6 @@ const char *TypeClass::kind()
return "class";
}

char *TypeClass::toChars()
{
if (mod)
return Type::toChars();
return (char *)sym->toPrettyChars();
}

Type *TypeClass::syntaxCopy()
{
return this;
Expand Down
7 changes: 0 additions & 7 deletions src/mtype.h
Expand Up @@ -400,7 +400,6 @@ class TypeBasic : public Type
unsigned alignsize();
Expression *getProperty(Loc loc, Identifier *ident, int flag);
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident, int flag);
char *toChars();
bool isintegral();
bool isfloating();
bool isreal();
Expand Down Expand Up @@ -430,7 +429,6 @@ class TypeVector : public Type
unsigned alignsize();
Expression *getProperty(Loc loc, Identifier *ident, int flag);
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident, int flag);
char *toChars();
bool isintegral();
bool isfloating();
bool isscalar();
Expand Down Expand Up @@ -688,7 +686,6 @@ class TypeIdentifier : public TypeQualified
TypeIdentifier(Loc loc, Identifier *ident);
const char *kind();
Type *syntaxCopy();
//char *toChars();
void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps, bool intypeid = false);
Dsymbol *toDsymbol(Scope *sc);
Type *semantic(Loc loc, Scope *sc);
Expand All @@ -706,7 +703,6 @@ class TypeInstance : public TypeQualified
TypeInstance(Loc loc, TemplateInstance *tempinst);
const char *kind();
Type *syntaxCopy();
//char *toChars();
void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps, bool intypeid = false);
Type *semantic(Loc loc, Scope *sc);
Dsymbol *toDsymbol(Scope *sc);
Expand Down Expand Up @@ -764,7 +760,6 @@ class TypeStruct : public Type
const char *kind();
d_uns64 size(Loc loc);
unsigned alignsize();
char *toChars();
Type *syntaxCopy();
Type *semantic(Loc loc, Scope *sc);
Dsymbol *toDsymbol(Scope *sc);
Expand Down Expand Up @@ -796,7 +791,6 @@ class TypeEnum : public Type
Type *syntaxCopy();
d_uns64 size(Loc loc);
unsigned alignsize();
char *toChars();
Type *semantic(Loc loc, Scope *sc);
Dsymbol *toDsymbol(Scope *sc);
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident, int flag);
Expand Down Expand Up @@ -833,7 +827,6 @@ class TypeClass : public Type
TypeClass(ClassDeclaration *sym);
const char *kind();
d_uns64 size(Loc loc);
char *toChars();
Type *syntaxCopy();
Type *semantic(Loc loc, Scope *sc);
Dsymbol *toDsymbol(Scope *sc);
Expand Down
4 changes: 2 additions & 2 deletions test/fail_compilation/fail9.d
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail9.d(25): Error: no property 'Vector' for type 'fail9.Vector!int.Vector'
fail_compilation/fail9.d(25): Error: no property 'Vector' for type 'fail9.Vector!int.Vector'
fail_compilation/fail9.d(25): Error: no property 'Vector' for type 'fail9.Vector!int'
fail_compilation/fail9.d(25): Error: no property 'Vector' for type 'fail9.Vector!int'
---
*/

Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/ice8100.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice8100.d(10): Error: no property 'Q' for type 'ice8100.Bar!bool.Bar'
fail_compilation/ice8100.d(10): Error: no property 'Q' for type 'ice8100.Bar!bool'
fail_compilation/ice8100.d(11): Error: template instance ice8100.Foo!(Bar!bool) error instantiating
fail_compilation/ice8100.d(12): instantiated from here: Bar!bool
---
Expand Down

0 comments on commit 2da20e0

Please sign in to comment.