Mercurial > projects > ddmd
view dmd/Identifier.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | 2e2a5c3f943a |
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); } }