Mercurial > projects > ddmd
view dmd/Identifier.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | ccbc1e0bb3f0 |
line wrap: on
line source
module dmd.Identifier; 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; } int equals(Object o) { return this is o || string_ == (cast(Identifier)o).toChars(); /// hack } hash_t hashCode() { assert(false); } int compare(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); } }