Mercurial > projects > ddmd
view dmd/Identifier.d @ 144:ea6325d0edd9
+ RealExp.toCBuffer
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Tue, 14 Sep 2010 22:39:29 +0100 |
parents | e28b18c23469 |
children | ceed63f310fb |
line wrap: on
line source
module dmd.Identifier; import dmd.common; import dmd.TOK; import dmd.DYNCAST; import dmd.Lexer; import dmd.OutBuffer; import std.stdio : writef; class Identifier { TOK value; string string_; this(string string_, TOK value) { this.string_ = string_; this.value = value; } bool equals(Object o) { return this is o || string_ == (cast(Identifier)o).toChars(); /// hack } 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) { static size_t i; return generateId(prefix, ++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); } }