Changeset 0dd3a2f for translator/SymTab/AggregateTable.h
- Timestamp:
- May 18, 2015, 11:20:23 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 51587aa
- Parents:
- a32b204
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SymTab/AggregateTable.h
ra32b204 r0dd3a2f 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 */ 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 // 7 15 8 #ifndef SYMTAB_AGGREGATETABLE_H9 #define SYMTAB_AGGREGATETABLE_H16 #ifndef AGGREGATETABLE_H 17 #define AGGREGATETABLE_H 10 18 11 19 #include <map> … … 18 26 19 27 namespace 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 }; 20 40 21 template< class AggregateDeclClass > 22 class AggregateTableConflictFunction : public std::binary_function< AggregateDeclClass*, AggregateDeclClass*, AggregateDeclClass* > 23 { 24 public: 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 37 typedef StackTable< StructDecl, AggregateTableConflictFunction< StructDecl > > StructTable; 38 typedef StackTable< EnumDecl, AggregateTableConflictFunction< EnumDecl > > EnumTable; 39 typedef StackTable< UnionDecl, AggregateTableConflictFunction< UnionDecl > > UnionTable; 40 typedef StackTable< ContextDecl, AggregateTableConflictFunction< ContextDecl > > ContextTable; 41 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; 42 45 } // namespace SymTab 43 46 44 #endif /* #ifndef SYMTAB_AGGREGATETABLE_H */ 47 #endif // AGGREGATETABLE_H 48 49 // Local Variables: // 50 // tab-width: 4 // 51 // mode: c++ // 52 // compile-command: "make install" // 53 // End: //
Note: See TracChangeset
for help on using the changeset viewer.