Mercurial > projects > ddmd
diff dmd/Identifier.d @ 174:af724d3510d7
lot os toCBuffer methods implemented
moved shared Type.* stuff into Global
author | korDen |
---|---|
date | Sun, 10 Oct 2010 03:47:23 +0400 |
parents | ceed63f310fb |
children | e3afd1303184 |
line wrap: on
line diff
--- a/dmd/Identifier.d Sun Oct 10 01:55:35 2010 +0400 +++ b/dmd/Identifier.d Sun Oct 10 03:47:23 2010 +0400 @@ -5,8 +5,11 @@ import dmd.DYNCAST; import dmd.Lexer; import dmd.Global; +import dmd.Id; import dmd.OutBuffer; +import std.string; + class Identifier { TOK value; @@ -17,40 +20,40 @@ this.string_ = string_; this.value = value; } - + bool equals(Object o) { if (this is o) { return true; } - + if (auto i = cast(Identifier)o) { return string_ == i.string_; } - + return false; } - + hash_t hashCode() { assert(false); } - + override int opCmp(Object o) { assert(false); } - + void print() { assert(false); } - + string toChars() { return string_; } - + version (_DH) { char* toHChars() { @@ -59,9 +62,31 @@ } string toHChars2() { - assert(false); + string p; + + if (this == Id.ctor) p = "this"; + else if (this == Id.dtor) p = "~this"; + else if (this == Id.classInvariant) p = "invariant"; + else if (this == Id.unitTest) p = "unittest"; + else if (this == Id.dollar) p = "$"; + else if (this == Id.withSym) p = "with"; + else if (this == Id.result) p = "result"; + else if (this == Id.returnLabel) p = "return"; + else + { + p = toChars(); + if (p.length != 0 && p[0] == '_') + { + if (p.startsWith("_staticCtor")) + p = "static this"; + else if (p.startsWith("_staticDtor")) + p = "static ~this"; + } + } + + return p; } - + DYNCAST dyncast() { return DYNCAST.DYNCAST_IDENTIFIER; @@ -72,7 +97,7 @@ { return generateId(prefix, ++global.i); } - + static Identifier generateId(string prefix, size_t i) { scope OutBuffer buf = new OutBuffer();