Mercurial > projects > dil
annotate trunk/src/dil/Identifier.d @ 499:52447db67938
Implemented global table of identifiers.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 09 Dec 2007 22:37:47 +0100 |
parents | 33b566df6af4 |
children | 4e14cd1b24da |
rev | line source |
---|---|
274 | 1 /++ |
2 Author: Aziz Köksal | |
3 License: GPL3 | |
4 +/ | |
326 | 5 module dil.Identifier; |
327 | 6 import dil.Token; |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
327
diff
changeset
|
7 import common; |
274 | 8 |
9 struct Identifier | |
10 { | |
11 TOK type; | |
12 string str; | |
13 | |
499
52447db67938
Implemented global table of identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
14 static Identifier* opCall(TOK type, string str) |
274 | 15 { |
499
52447db67938
Implemented global table of identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
16 auto i = new Identifier; |
274 | 17 i.type = type; |
18 i.str = str; | |
19 return i; | |
20 } | |
21 | |
22 uint toHash() | |
23 { | |
24 uint hash; | |
25 foreach(c; str) { | |
26 hash *= 9; | |
27 hash += c; | |
28 } | |
29 return hash; | |
30 } | |
31 } |