source: translator/SymTab/AggregateTable.h @ 02e9ae2

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 02e9ae2 was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[51b7345]1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: AggregateTable.h,v 1.4 2005/08/29 20:14:17 rcbilson Exp $
5 *
6 */
7
8#ifndef SYMTAB_AGGREGATETABLE_H
9#define SYMTAB_AGGREGATETABLE_H
10
11#include <map>
12#include <stack>
13#include <string>
14#include <functional>
15
16#include "StackTable.h"
17#include "SynTree/Declaration.h"
18
19namespace SymTab {
20
21template< class AggregateDeclClass >
22class AggregateTableConflictFunction : public std::binary_function< AggregateDeclClass*, AggregateDeclClass*, AggregateDeclClass* >
23{
24public:
25  AggregateDeclClass *operator()( AggregateDeclClass *existing, AggregateDeclClass *added )
26  {
27    if( existing->get_members().empty() ) {
28      return added;
29    } else if( !added->get_members().empty() ) {
30      throw SemanticError( "redeclaration of ", added );
31    }
32    return existing;
33  }
34 
35};
36
37typedef StackTable< StructDecl, AggregateTableConflictFunction< StructDecl > > StructTable;
38typedef StackTable< EnumDecl, AggregateTableConflictFunction< EnumDecl > > EnumTable;
39typedef StackTable< UnionDecl, AggregateTableConflictFunction< UnionDecl > > UnionTable;
40typedef StackTable< ContextDecl, AggregateTableConflictFunction< ContextDecl > > ContextTable;
41
42} // namespace SymTab
43
44#endif /* #ifndef SYMTAB_AGGREGATETABLE_H */
Note: See TracBrowser for help on using the repository browser.