Mercurial > projects > dmdscript-tango
diff dmdscript_tango/identifier.d @ 0:55c2951c07be
initial, files origin, premoved tree
author | saaadel |
---|---|
date | Sun, 24 Jan 2010 12:34:47 +0200 |
parents | |
children | 8363a4bf6a8f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmdscript_tango/identifier.d Sun Jan 24 12:34:47 2010 +0200 @@ -0,0 +1,57 @@ + +/* Digital Mars DMDScript source code. + * Copyright (c) 2000-2002 by Chromium Communications + * D version Copyright (c) 2004-2009 by Digital Mars + * All Rights Reserved + * written by Walter Bright + * http://www.digitalmars.com + * Use at your own risk. There is no warranty, express or implied. + * License for redistribution is by the GNU General Public License in gpl.txt. + * + * A binary, non-exclusive license for commercial use can be + * purchased from www.digitalmars.com/dscript/buy.html. + * + * DMDScript is implemented in the D Programming Language, + * www.digitalmars.com/d/ + * + * For a C++ implementation of DMDScript, including COM support, + * see www.digitalmars.com/dscript/cppscript.html. + */ + +module dmdscript.identifier; + +import dmdscript.script; +import dmdscript.value; + +/* An Identifier is a special case of a Value - it is a V_STRING + * and has the hash value computed and set. + */ + +struct Identifier +{ + Value value; + + tchar[] toString() + { + return value.string; + } + + int opEquals(Identifier *id) + { + return this is id || value.string == id.value.string; + } + + static Identifier* build(tchar[] s) + { Identifier* id = new Identifier; + id.value.putVstring(s); + id.value.toHash(); + return id; + } + + uint toHash() + { + return value.hash; + } +} + +