Changeset bdd516a for translator/SymTab/IdTable.cc
- 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
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.