source: translator/SymTab/AggregateTable.h@ fe3b61b

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since fe3b61b was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[51b73452]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.