view trunk/src/dil/Symbol.d @ 567:ab9f5020cd02

Added 'is-methods' to class Symbol.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 29 Dec 2007 14:44:09 +0100
parents c838ed7f2ac9
children c8861b452eb3
line wrap: on
line source

/++
  Author: Aziz Köksal
  License: GPL3
+/
module dil.Symbol;

import common;

/// Symbol IDs.
enum SYM
{
  Module,
  Class,
  Interface,
  Struct,
  Union,
  Variable,
  Function,
  Type,
}

/++
  A symbol represents an object with semantic code information.
+/
class Symbol
{
  SYM sid;

  // A template macro for building isXYZ() methods.
  private template is_(char[] kind)
  {
    const char[] is_ = `bool is`~kind~`(){ return sid == SYM.`~kind~`; }`;
  }
  mixin(is_!("Module"));
  mixin(is_!("Class"));
  mixin(is_!("Interface"));
  mixin(is_!("Struct"));
  mixin(is_!("Union"));
  mixin(is_!("Variable"));
  mixin(is_!("Function"));
  mixin(is_!("Type"));
}