Mercurial > projects > ddmd
view dmd/Identifier.d @ 168:ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
author | korDen |
---|---|
date | Thu, 30 Sep 2010 12:57:13 +0400 |
parents | e28b18c23469 |
children | af724d3510d7 |
line wrap: on
line source
module dmd.Identifier; import dmd.common; import dmd.TOK; import dmd.DYNCAST; import dmd.Lexer; import dmd.Global; import dmd.OutBuffer; class Identifier { TOK value; string string_; this(string string_, TOK value) { 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() { assert(false); } } string toHChars2() { assert(false); } DYNCAST dyncast() { return DYNCAST.DYNCAST_IDENTIFIER; } // BUG: these are redundant with Lexer::uniqueId() static Identifier generateId(string prefix) { return generateId(prefix, ++global.i); } static Identifier generateId(string prefix, size_t i) { scope OutBuffer buf = new OutBuffer(); buf.writestring(prefix); buf.printf("%d", i); ///<! string id = buf.extractString(); return Lexer.idPool(id); } }