/*
 * This file is part of the Cforall project
 *
 * $Id: IdTable.h,v 1.4 2005/08/29 20:14:17 rcbilson Exp $
 *
 */

#ifndef SYMTAB_IDTABLE_H
#define SYMTAB_IDTABLE_H

#include <iostream>
#include <map>
#include <string>
#include <stack>

#include "SynTree/SynTree.h"

namespace SymTab {

class IdTable
{
public:
  IdTable();
  
  void enterScope();
  void leaveScope();
  void addDecl( DeclarationWithType *decl );
  void lookupId( const std::string &id, std::list< DeclarationWithType* >& decls ) const;
  
  void dump( std::ostream &os ) const; // debugging

 private:
  typedef std::pair< DeclarationWithType*, int > DeclEntry;
  typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType;
  typedef std::map< std::string, InnerTableType > OuterTableType;

  OuterTableType table;
  int scopeLevel;
};

} // namespace SymTab

#endif /* #ifndef SYMTAB_IDTABLE_H */
