comparison 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
comparison
equal deleted inserted replaced
167:50a6d232176c 168:ceed63f310fb
2 2
3 import dmd.common; 3 import dmd.common;
4 import dmd.TOK; 4 import dmd.TOK;
5 import dmd.DYNCAST; 5 import dmd.DYNCAST;
6 import dmd.Lexer; 6 import dmd.Lexer;
7 import dmd.Global;
7 import dmd.OutBuffer; 8 import dmd.OutBuffer;
8
9 import std.stdio : writef;
10 9
11 class Identifier 10 class Identifier
12 { 11 {
13 TOK value; 12 TOK value;
14 string string_; 13 string string_;
19 this.value = value; 18 this.value = value;
20 } 19 }
21 20
22 bool equals(Object o) 21 bool equals(Object o)
23 { 22 {
24 return this is o || string_ == (cast(Identifier)o).toChars(); /// hack 23 if (this is o) {
24 return true;
25 }
26
27 if (auto i = cast(Identifier)o) {
28 return string_ == i.string_;
29 }
30
31 return false;
25 } 32 }
26 33
27 hash_t hashCode() 34 hash_t hashCode()
28 { 35 {
29 assert(false); 36 assert(false);
61 } 68 }
62 69
63 // BUG: these are redundant with Lexer::uniqueId() 70 // BUG: these are redundant with Lexer::uniqueId()
64 static Identifier generateId(string prefix) 71 static Identifier generateId(string prefix)
65 { 72 {
66 static size_t i; 73 return generateId(prefix, ++global.i);
67 return generateId(prefix, ++i);
68 } 74 }
69 75
70 static Identifier generateId(string prefix, size_t i) 76 static Identifier generateId(string prefix, size_t i)
71 { 77 {
72 scope OutBuffer buf = new OutBuffer(); 78 scope OutBuffer buf = new OutBuffer();