view dmdscript_tango/identifier.d @ 3:8363a4bf6a8f

rename package: dmdscript to dmdscript_tango
author saaadel
date Sun, 24 Jan 2010 18:33:05 +0200
parents 55c2951c07be
children
line wrap: on
line source


/* 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_tango.identifier;

import dmdscript_tango.script;
import dmdscript_tango.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;
    }
}