Changeset bdd516a for translator/SymTab
- Timestamp:
- Apr 28, 2015, 4:21:36 PM (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:
- 42e2ad7
- Parents:
- ad17ba6a
- Location:
- translator/SymTab
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SymTab/IdTable.cc
rad17ba6a rbdd516a 82 82 } 83 83 } 84 for( InnerTableType::const_iterator i = declTable.begin(); i != declTable.end(); ++i ) { 84 // ensure the set of routines with C linkage cannot be overloaded 85 for( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) { 85 86 if( !i->second.empty() && i->second.top().first->get_linkage() == LinkageSpec::C && declTable.size() > 1 ) { 86 throw SemanticError( "invalid overload of C function ", i->second.top().first ); 87 InnerTableType::iterator j = i; 88 for( j++; j != declTable.end(); ++j ) { 89 if( !j->second.empty() && j->second.top().first->get_linkage() == LinkageSpec::C ) { 90 throw SemanticError( "invalid overload of C function " ); 91 } 92 } 87 93 } 88 94 } … … 103 109 } 104 110 111 DeclarationWithType* IdTable::lookupId( const std::string &id) const { 112 DeclarationWithType* result = 0; 113 int depth = -1; 114 115 OuterTableType::const_iterator outer = table.find( id ); 116 if( outer == table.end() ) return 0; 117 const InnerTableType &declTable = outer->second; 118 for( InnerTableType::const_iterator it = declTable.begin(); it != declTable.end(); ++it ) { 119 const std::stack< DeclEntry >& entry = it->second; 120 if( !entry.empty() && entry.top().second > depth ) { 121 result = entry.top().first; 122 depth = entry.top().second; 123 } 124 } 125 return result; 126 } 127 105 128 void 106 129 IdTable::dump( std::ostream &os ) const 107 130 { 131 for( OuterTableType::const_iterator outer = table.begin(); outer != table.end(); ++outer ) { 132 for( InnerTableType::const_iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) { 133 #if 0 134 const std::stack< DeclEntry >& entry = inner->second; 135 if( !entry.empty() ) { // && entry.top().second == scopeLevel ) { 136 os << outer->first << " (" << inner->first << ") (" << entry.top().second << ")" << std::endl; 137 } else { 138 os << outer->first << " (" << inner->first << ") ( entry-empty)" << std::endl; 139 } 140 #endif 141 #if 0 142 std::stack<DeclEntry> stack = inner->second; 143 os << "dumping a stack" << std::endl; 144 while (!stack.empty()) { 145 DeclEntry d = stack.top(); 146 os << outer->first << " (" << inner->first << ") (" << d.second << ") " << std::endl; 147 stack.pop(); 148 } 149 #endif 150 } 151 } 152 #if 0 108 153 for( OuterTableType::const_iterator outer = table.begin(); outer != table.end(); ++outer ) { 109 154 for( InnerTableType::const_iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) { … … 114 159 } 115 160 } 161 #endif 116 162 } 117 163 -
translator/SymTab/IdTable.h
rad17ba6a rbdd516a 1 /*2 * This file is part of the Cforall project3 *4 * $Id: IdTable.h,v 1.4 2005/08/29 20:14:17 rcbilson Exp $5 *6 */7 8 1 #ifndef SYMTAB_IDTABLE_H 9 2 #define SYMTAB_IDTABLE_H … … 17 10 18 11 namespace SymTab { 12 class IdTable { 13 public: 14 IdTable(); 15 16 void enterScope(); 17 void leaveScope(); 18 void addDecl( DeclarationWithType *decl ); 19 void lookupId( const std::string &id, std::list< DeclarationWithType* >& decls ) const; 20 DeclarationWithType* lookupId( const std::string &id) const; 21 22 void dump( std::ostream &os ) const; // debugging 19 23 20 class IdTable 21 { 22 public: 23 IdTable(); 24 25 void enterScope(); 26 void leaveScope(); 27 void addDecl( DeclarationWithType *decl ); 28 void lookupId( const std::string &id, std::list< DeclarationWithType* >& decls ) const; 29 30 void dump( std::ostream &os ) const; // debugging 24 private: 25 typedef std::pair< DeclarationWithType*, int > DeclEntry; 26 typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType; 27 typedef std::map< std::string, InnerTableType > OuterTableType; 31 28 32 private: 33 typedef std::pair< DeclarationWithType*, int > DeclEntry; 34 typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType; 35 typedef std::map< std::string, InnerTableType > OuterTableType; 36 37 OuterTableType table; 38 int scopeLevel; 39 }; 40 29 OuterTableType table; 30 int scopeLevel; 31 }; 41 32 } // namespace SymTab 42 33 43 #endif / * #ifndef SYMTAB_IDTABLE_H */34 #endif // SYMTAB_IDTABLE_H -
translator/SymTab/Indexer.cc
rad17ba6a rbdd516a 162 162 } 163 163 164 DeclarationWithType* Indexer::lookupId( const std::string &id) const { 165 return idTable.lookupId(id); 166 } 167 164 168 NamedTypeDecl *Indexer::lookupType( const std::string &id ) const { 165 169 return typeTable.lookup( id ); … … 216 220 217 221 void Indexer::print( std::ostream &os, int indent ) const { 222 using std::cerr; 223 using std::endl; 224 225 cerr << "===idTable===" << endl; 226 idTable.dump( os ); 227 cerr << "===typeTable===" << endl; 228 typeTable.dump( os ); 229 cerr << "===structTable===" << endl; 230 structTable.dump( os ); 231 cerr << "===enumTable===" << endl; 232 enumTable.dump( os ); 233 cerr << "===unionTable===" << endl; 234 unionTable.dump( os ); 235 cerr << "===contextTable===" << endl; 236 contextTable.dump( os ); 237 #if 0 218 238 idTable.dump( os ); 219 239 typeTable.dump( os ); … … 222 242 unionTable.dump( os ); 223 243 contextTable.dump( os ); 244 #endif 224 245 } 225 246 } // namespace SymTab -
translator/SymTab/Indexer.h
rad17ba6a rbdd516a 39 39 40 40 void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const; 41 DeclarationWithType* lookupId( const std::string &id) const; 41 42 NamedTypeDecl *lookupType( const std::string &id ) const; 42 43 StructDecl *lookupStruct( const std::string &id ) const; … … 58 59 } // namespace SymTab 59 60 60 #endif / * #ifndef SYMTAB_INDEXER_H */61 #endif // SYMTAB_INDEXER_H -
translator/SymTab/Mangler.cc
rad17ba6a rbdd516a 226 226 mangleName << "L"; 227 227 } 228 if ( type->get_isAtomic() ) { 229 mangleName << "A"; 230 } 228 231 } 229 232 } // SymTab -
translator/SymTab/Validate.cc
rad17ba6a rbdd516a 278 278 ObjectDecl *obj = dynamic_cast< ObjectDecl * >( *i ); 279 279 assert( obj ); 280 obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false ), enumDecl->get_name() ) );280 obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false ), enumDecl->get_name() ) ); 281 281 } // for 282 282 Parent::visit( enumDecl );
Note: See TracChangeset
for help on using the changeset viewer.