view 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
line wrap: on
line source

/++
  Author: Aziz Köksal
  License: GPL3
+/
module dil.Identifier;
import dil.Token;
import common;

struct Identifier
{
  TOK type;
  string str;

  static Identifier* opCall(TOK type, string str)
  {
    auto i = new Identifier;
    i.type = type;
    i.str = str;
    return i;
  }

  uint toHash()
  {
    uint hash;
    foreach(c; str) {
      hash *= 9;
      hash += c;
    }
    return hash;
  }
}