1 
2 /* Digital Mars DMDScript source code.
3  * Copyright (c) 2000-2002 by Chromium Communications
4  * D version Copyright (c) 2004-2010 by Digital Mars
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  * written by Walter Bright
8  * http://www.digitalmars.com
9  *
10  * D2 port by Dmitry Olshansky 
11  *
12  * DMDScript is implemented in the D Programming Language,
13  * http://www.digitalmars.com/d/
14  *
15  * For a C++ implementation of DMDScript, including COM support, see
16  * http://www.digitalmars.com/dscript/cppscript.html
17  */
18 
19 module dmdscript.identifier;
20 
21 import dmdscript.script;
22 import dmdscript.value;
23 
24 /* An Identifier is a special case of a Value - it is a V_STRING
25  * and has the hash value computed and set.
26  */
27 
28 struct Identifier
29 {
30     Value    value;
31 
32     d_string toString()
33     {
34         return value..string;
35     }
36 
37     const bool opEquals(ref const (Identifier)id)
38     {
39         return this is id || value..string == id.value..string;
40     }
41 
42     static Identifier* build(d_string s)
43     {
44         Identifier* id = new Identifier;
45         id.value.putVstring(s);
46         id.value.toHash();
47         return id;
48     }
49 
50     uint toHash()
51     {
52         return value.hash;
53     }
54 }
55 
56