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

#ifndef SYMTAB_TYPETABLE_H
#define SYMTAB_TYPETABLE_H

#include <cassert>
#include <map>
#include <stack>
#include <string>
#include <functional>

#include "StackTable.h"
#include "SynTree/Declaration.h"

namespace SymTab {

class TypeTableConflictFunction : public std::binary_function< NamedTypeDecl*, NamedTypeDecl*, NamedTypeDecl* >
{
public:
  NamedTypeDecl *operator()( NamedTypeDecl *existing, NamedTypeDecl *added )
  {
    if( existing->get_base() == 0 ) {
      return added;
    } else if( added->get_base() == 0 ) {
      return existing;
    } else {
      throw SemanticError( "redeclaration of ", added );
    }
    assert( false );
    return 0;
  }
  
};

typedef StackTable< NamedTypeDecl, TypeTableConflictFunction > TypeTable;

} // namespace SymTab

#endif /* #ifndef SYMTAB_TYPETABLE_H */
