Ignore:
Timestamp:
May 19, 2015, 4:58:14 PM (11 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, stuck-waitfor-destruct, with_gc
Children:
843054c2
Parents:
01aeade
Message:

licencing: sixth groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/SymTab/Indexer.cc

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:37:33 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:38:44 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:49:55 2015
     13// Update Count     : 3
    1414//
    1515
     
    2626
    2727namespace SymTab {
    28     Indexer::Indexer( bool useDebug ) : doDebug( useDebug ) {}
    29 
    30     Indexer::~Indexer() {}
    31 
    32     void Indexer::visit( ObjectDecl *objectDecl ) {
     28        Indexer::Indexer( bool useDebug ) : doDebug( useDebug ) {}
     29
     30        Indexer::~Indexer() {}
     31
     32        void Indexer::visit( ObjectDecl *objectDecl ) {
    3333                maybeAccept( objectDecl->get_type(), *this );
    3434                maybeAccept( objectDecl->get_init(), *this );
     
    3838                        idTable.addDecl( objectDecl );
    3939                } // if
    40     }
    41 
    42     void Indexer::visit( FunctionDecl *functionDecl ) {
     40        }
     41
     42        void Indexer::visit( FunctionDecl *functionDecl ) {
    4343                if ( functionDecl->get_name() == "" ) return;
    4444                debugPrint( "Adding function " << functionDecl->get_name() << std::endl );
     
    4949                maybeAccept( functionDecl->get_statements(), *this );
    5050                leaveScope();
    51     }
     51        }
    5252
    5353/********
     
    7070 */
    7171
    72     void Indexer::visit( TypeDecl *typeDecl ) {
     72        void Indexer::visit( TypeDecl *typeDecl ) {
    7373                // see A NOTE ON THE ORDER OF TRAVERSAL, above
    7474                // note that assertions come after the type is added to the symtab, since they aren't part
     
    8181                typeTable.add( typeDecl );
    8282                acceptAll( typeDecl->get_assertions(), *this );
    83     }
    84 
    85     void Indexer::visit( TypedefDecl *typeDecl ) {
     83        }
     84
     85        void Indexer::visit( TypedefDecl *typeDecl ) {
    8686                enterScope();
    8787                acceptAll( typeDecl->get_parameters(), *this );
     
    9090                debugPrint( "Adding typedef " << typeDecl->get_name() << std::endl );
    9191                typeTable.add( typeDecl );
    92     }
    93 
    94     void Indexer::visit( StructDecl *aggregateDecl ) {
     92        }
     93
     94        void Indexer::visit( StructDecl *aggregateDecl ) {
    9595                // make up a forward declaration and add it before processing the members
    9696                StructDecl fwdDecl( aggregateDecl->get_name() );
     
    107107                // this addition replaces the forward declaration
    108108                structTable.add( aggregateDecl );
    109     }
    110 
    111     void Indexer::visit( UnionDecl *aggregateDecl ) {
     109        }
     110
     111        void Indexer::visit( UnionDecl *aggregateDecl ) {
    112112                // make up a forward declaration and add it before processing the members
    113113                UnionDecl fwdDecl( aggregateDecl->get_name() );
     
    123123                debugPrint( "Adding union " << aggregateDecl->get_name() << std::endl );
    124124                unionTable.add( aggregateDecl );
    125     }
    126 
    127     void Indexer::visit( EnumDecl *aggregateDecl ) {
     125        }
     126
     127        void Indexer::visit( EnumDecl *aggregateDecl ) {
    128128                debugPrint( "Adding enum " << aggregateDecl->get_name() << std::endl );
    129129                enumTable.add( aggregateDecl );
    130130                // unlike structs, contexts, and unions, enums inject their members into the global scope
    131131                acceptAll( aggregateDecl->get_members(), *this );
    132     }
    133 
    134     void Indexer::visit( ContextDecl *aggregateDecl ) {
     132        }
     133
     134        void Indexer::visit( ContextDecl *aggregateDecl ) {
    135135                enterScope();
    136136                acceptAll( aggregateDecl->get_parameters(), *this );
     
    140140                debugPrint( "Adding context " << aggregateDecl->get_name() << std::endl );
    141141                contextTable.add( aggregateDecl );
    142     }
    143 
    144     void Indexer::visit( CompoundStmt *compoundStmt ) {
     142        }
     143
     144        void Indexer::visit( CompoundStmt *compoundStmt ) {
    145145                enterScope();
    146146                acceptAll( compoundStmt->get_kids(), *this );
    147147                leaveScope();
    148     }
    149 
    150     void Indexer::visit( ContextInstType *contextInst ) {
     148        }
     149
     150        void Indexer::visit( ContextInstType *contextInst ) {
    151151                acceptAll( contextInst->get_parameters(), *this );
    152152                acceptAll( contextInst->get_members(), *this );
    153     }
    154 
    155     void Indexer::visit( StructInstType *structInst ) {
     153        }
     154
     155        void Indexer::visit( StructInstType *structInst ) {
    156156                if ( ! structTable.lookup( structInst->get_name() ) ) {
    157157                        debugPrint( "Adding struct " << structInst->get_name() << " from implicit forward declaration" << std::endl );
     
    161161                acceptAll( structInst->get_parameters(), *this );
    162162                leaveScope();
    163     }
    164 
    165     void Indexer::visit( UnionInstType *unionInst ) {
     163        }
     164
     165        void Indexer::visit( UnionInstType *unionInst ) {
    166166                if ( ! unionTable.lookup( unionInst->get_name() ) ) {
    167167                        debugPrint( "Adding union " << unionInst->get_name() << " from implicit forward declaration" << std::endl );
     
    171171                acceptAll( unionInst->get_parameters(), *this );
    172172                leaveScope();
    173     }
    174 
    175     void Indexer::visit( ForStmt *forStmt ) {
    176         // for statements introduce a level of scope
    177         enterScope();
    178         Visitor::visit( forStmt );
    179         leaveScope();
    180     }
    181 
    182 
    183     void Indexer::lookupId( const std::string &id, std::list< DeclarationWithType* > &list ) const {
     173        }
     174
     175        void Indexer::visit( ForStmt *forStmt ) {
     176            // for statements introduce a level of scope
     177            enterScope();
     178            Visitor::visit( forStmt );
     179            leaveScope();
     180        }
     181
     182
     183        void Indexer::lookupId( const std::string &id, std::list< DeclarationWithType* > &list ) const {
    184184                idTable.lookupId( id, list );
    185     }
    186 
    187     DeclarationWithType* Indexer::lookupId( const std::string &id) const {
     185        }
     186
     187        DeclarationWithType* Indexer::lookupId( const std::string &id) const {
    188188                return idTable.lookupId(id);
    189     }
    190 
    191     NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
     189        }
     190
     191        NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
    192192                return typeTable.lookup( id );
    193     }
    194 
    195     StructDecl *Indexer::lookupStruct( const std::string &id ) const {
     193        }
     194
     195        StructDecl *Indexer::lookupStruct( const std::string &id ) const {
    196196                return structTable.lookup( id );
    197     }
    198 
    199     EnumDecl *Indexer::lookupEnum( const std::string &id ) const {
     197        }
     198
     199        EnumDecl *Indexer::lookupEnum( const std::string &id ) const {
    200200                return enumTable.lookup( id );
    201     }
    202 
    203     UnionDecl *Indexer::lookupUnion( const std::string &id ) const {
     201        }
     202
     203        UnionDecl *Indexer::lookupUnion( const std::string &id ) const {
    204204                return unionTable.lookup( id );
    205     }
    206 
    207     ContextDecl  * Indexer::lookupContext( const std::string &id ) const {
     205        }
     206
     207        ContextDecl  * Indexer::lookupContext( const std::string &id ) const {
    208208                return contextTable.lookup( id );
    209     }
    210 
    211     void Indexer::enterScope() {
     209        }
     210
     211        void Indexer::enterScope() {
    212212                if ( doDebug ) {
    213213                        std::cout << "--- Entering scope" << std::endl;
     
    219219                unionTable.enterScope();
    220220                contextTable.enterScope();
    221     }
    222 
    223     void Indexer::leaveScope() {
     221        }
     222
     223        void Indexer::leaveScope() {
    224224                using std::cout;
    225225                using std::endl;
     
    240240                unionTable.leaveScope();
    241241                contextTable.leaveScope();
    242     }
    243 
    244     void Indexer::print( std::ostream &os, int indent ) const {
    245         using std::cerr;
    246         using std::endl;
    247 
    248         cerr << "===idTable===" << endl;
    249         idTable.dump( os );
    250         cerr << "===typeTable===" << endl;
    251         typeTable.dump( os );
    252         cerr << "===structTable===" << endl;
    253         structTable.dump( os );
    254         cerr << "===enumTable===" << endl;
    255         enumTable.dump( os );
    256         cerr << "===unionTable===" << endl;
    257         unionTable.dump( os );
    258         cerr << "===contextTable===" << endl;
    259         contextTable.dump( os );
     242        }
     243
     244        void Indexer::print( std::ostream &os, int indent ) const {
     245            using std::cerr;
     246            using std::endl;
     247
     248            cerr << "===idTable===" << endl;
     249            idTable.dump( os );
     250            cerr << "===typeTable===" << endl;
     251            typeTable.dump( os );
     252            cerr << "===structTable===" << endl;
     253            structTable.dump( os );
     254            cerr << "===enumTable===" << endl;
     255            enumTable.dump( os );
     256            cerr << "===unionTable===" << endl;
     257            unionTable.dump( os );
     258            cerr << "===contextTable===" << endl;
     259            contextTable.dump( os );
    260260#if 0
    261261                idTable.dump( os );
     
    266266                contextTable.dump( os );
    267267#endif
    268     }
     268        }
    269269} // namespace SymTab
    270270
Note: See TracChangeset for help on using the changeset viewer.