Changeset bdd516a for translator/SymTab


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

Location:
translator/SymTab
Files:
6 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
  • translator/SymTab/IdTable.h

    rad17ba6a rbdd516a  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: IdTable.h,v 1.4 2005/08/29 20:14:17 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef SYMTAB_IDTABLE_H
    92#define SYMTAB_IDTABLE_H
     
    1710
    1811namespace 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
    1923
    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;
    3128
    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    };
    4132} // namespace SymTab
    4233
    43 #endif /* #ifndef SYMTAB_IDTABLE_H */
     34#endif // SYMTAB_IDTABLE_H
  • translator/SymTab/Indexer.cc

    rad17ba6a rbdd516a  
    162162    }
    163163
     164    DeclarationWithType* Indexer::lookupId( const std::string &id) const {
     165        return idTable.lookupId(id);
     166    }
     167
    164168    NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
    165169        return typeTable.lookup( id );
     
    216220
    217221    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
    218238        idTable.dump( os );
    219239        typeTable.dump( os );
     
    222242        unionTable.dump( os );
    223243        contextTable.dump( os );
     244#endif
    224245    }
    225246} // namespace SymTab
  • translator/SymTab/Indexer.h

    rad17ba6a rbdd516a  
    3939
    4040        void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
     41        DeclarationWithType* lookupId( const std::string &id) const;
    4142        NamedTypeDecl *lookupType( const std::string &id ) const;
    4243        StructDecl *lookupStruct( const std::string &id ) const;
     
    5859} // namespace SymTab
    5960
    60 #endif /* #ifndef SYMTAB_INDEXER_H */
     61#endif // SYMTAB_INDEXER_H
  • translator/SymTab/Mangler.cc

    rad17ba6a rbdd516a  
    226226            mangleName << "L";
    227227        }
     228        if ( type->get_isAtomic() ) {
     229            mangleName << "A";
     230        }
    228231    }
    229232} // SymTab
  • translator/SymTab/Validate.cc

    rad17ba6a rbdd516a  
    278278            ObjectDecl *obj = dynamic_cast< ObjectDecl * >( *i );
    279279            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() ) );
    281281        } // for
    282282        Parent::visit( enumDecl );
Note: See TracChangeset for help on using the changeset viewer.