source: src/SymTab/AggregateTable.h @ ecb1534

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 ecb1534 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

licencing: seventh groups of files

  • Property mode set to 100644
File size: 1.6 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// AggregateTable.h --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 16:17:26 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sun May 17 16:19:29 2015
13// Update Count     : 4
14//
15
16#ifndef AGGREGATETABLE_H
17#define AGGREGATETABLE_H
18
19#include <map>
20#include <stack>
21#include <string>
22#include <functional>
23
24#include "StackTable.h"
25#include "SynTree/Declaration.h"
26
27namespace SymTab {
28        template< class AggregateDeclClass >
29        class AggregateTableConflictFunction : public std::binary_function< AggregateDeclClass *, AggregateDeclClass *, AggregateDeclClass *> {
30          public:
31                AggregateDeclClass *operator()( AggregateDeclClass *existing, AggregateDeclClass *added ) {
32                        if ( existing->get_members().empty() ) {
33                                return added;
34                        } else if ( ! added->get_members().empty() ) {
35                                throw SemanticError( "redeclaration of ", added );
36                        } // if
37                        return existing;
38                }
39        };
40
41        typedef StackTable< StructDecl, AggregateTableConflictFunction< StructDecl > > StructTable;
42        typedef StackTable< EnumDecl, AggregateTableConflictFunction< EnumDecl > > EnumTable;
43        typedef StackTable< UnionDecl, AggregateTableConflictFunction< UnionDecl > > UnionTable;
44        typedef StackTable< ContextDecl, AggregateTableConflictFunction< ContextDecl > > ContextTable;
45} // namespace SymTab
46
47#endif // AGGREGATETABLE_H
48
49// Local Variables: //
50// tab-width: 4 //
51// mode: c++ //
52// compile-command: "make install" //
53// End: //
Note: See TracBrowser for help on using the repository browser.