Ignore:
Timestamp:
Apr 28, 2015, 4:21:36 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

fixed sizeof type variable, find lowest cost alternative for sizeof expression, removed unused classes, added compiler flag, remove temporary file for -CFA, formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/SymTab/IdTable.cc

    rad17ba6a rbdd516a  
    8282    }
    8383  }
    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 ) {
    8586    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        }
    8793    }
    8894  }
     
    103109}
    104110
     111DeclarationWithType* 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
    105128void
    106129IdTable::dump( std::ostream &os ) const
    107130{
     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
    108153  for( OuterTableType::const_iterator outer = table.begin(); outer != table.end(); ++outer ) {
    109154    for( InnerTableType::const_iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) {
     
    114159    }
    115160  }
     161#endif
    116162}
    117163
Note: See TracChangeset for help on using the changeset viewer.