view trunk/src/dil/semantic/SymbolTable.d @ 707:efa5fcb9aa14

Added semantic code related to enums. Added member symbol to EnumMemberDeclaration. Added genAnonEnumID() to IdTable. Added class EnumMember. Wrote code for SemanticPass2.visit(EnumDeclaration). Revised code in SemanticPass1.visit(EnumDeclaration).
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 29 Jan 2008 01:07:39 +0100
parents 041eae272362
children c24be8d4f6ab
line wrap: on
line source

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

import dil.semantic.Symbol;
import dil.lexer.Identifier;
import common;

/++
  Maps an identifier string to a Symbol.
+/
struct SymbolTable
{
  Symbol[char[]] table;

  /// Look up ident in the table.
  Symbol lookup(Identifier* ident)
  {
    assert(ident !is null);
    auto psym = ident.str in table;
    return psym ? *psym : null;
  }

  void insert(Symbol s, Identifier* ident)
  {
    table[ident.str] = s;
  }
}