Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r6fc5c14 r33a25f9  
    4040
    4141namespace SymTab {
     42        struct NewScope {
     43                NewScope( SymTab::Indexer & indexer ) : indexer( indexer ) { indexer.enterScope(); }
     44                ~NewScope() { indexer.leaveScope(); }
     45                SymTab::Indexer & indexer;
     46        };
     47
     48        template< typename TreeType, typename VisitorType >
     49        inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) {
     50                visitor.enterScope();
     51                maybeAccept( tree, visitor );
     52                visitor.leaveScope();
     53        }
     54
    4255        typedef std::unordered_map< std::string, DeclarationWithType* > MangleTable;
    4356        typedef std::unordered_map< std::string, MangleTable > IdTable;
     
    185198        }
    186199
    187         Indexer::Indexer() : tables( 0 ), scope( 0 ) {}
    188 
    189         Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) {}
    190 
    191         Indexer::Indexer( Indexer &&that ) : doDebug( that.doDebug ), tables( that.tables ), scope( that.scope ) {
     200        Indexer::Indexer( bool _doDebug ) : tables( 0 ), scope( 0 ), doDebug( _doDebug ) {}
     201
     202        Indexer::Indexer( const Indexer &that ) : tables( newRef( that.tables ) ), scope( that.scope ), doDebug( that.doDebug ) {}
     203
     204        Indexer::Indexer( Indexer &&that ) : tables( that.tables ), scope( that.scope ), doDebug( that.doDebug ) {
    192205                that.tables = 0;
    193206        }
     
    407420                makeWritable();
    408421
    409                 const std::string &name = decl->name;
     422                const std::string &name = decl->get_name();
    410423                std::string mangleName;
    411                 if ( LinkageSpec::isOverridable( decl->linkage ) ) {
     424                if ( LinkageSpec::isOverridable( decl->get_linkage() ) ) {
    412425                        // mangle the name without including the appropriate suffix, so overridable routines are placed into the
    413426                        // same "bucket" as their user defined versions.
     
    418431
    419432                // this ensures that no two declarations with the same unmangled name at the same scope both have C linkage
    420                 if ( ! LinkageSpec::isMangled( decl->linkage ) ) {
     433                if ( ! LinkageSpec::isMangled( decl->get_linkage() ) ) {
    421434                        // NOTE this is broken in Richard's original code in such a way that it never triggers (it
    422435                        // doesn't check decls that have the same manglename, and all C-linkage decls are defined to
     
    571584
    572585                if ( doDebug ) {
    573                         std::cerr << "--- Entering scope " << scope << std::endl;
     586                        std::cout << "--- Entering scope " << scope << std::endl;
    574587                }
    575588        }
    576589
    577590        void Indexer::leaveScope() {
    578                 using std::cerr;
     591                using std::cout;
    579592
    580593                assert( scope > 0 && "cannot leave initial scope" );
    581                 if ( doDebug ) {
    582                         cerr << "--- Leaving scope " << scope << " containing" << std::endl;
    583                 }
    584594                --scope;
    585595
    586596                while ( tables && tables->scope > scope ) {
    587597                        if ( doDebug ) {
    588                                 dump( tables->idTable, cerr );
    589                                 dump( tables->typeTable, cerr );
    590                                 dump( tables->structTable, cerr );
    591                                 dump( tables->enumTable, cerr );
    592                                 dump( tables->unionTable, cerr );
    593                                 dump( tables->traitTable, cerr );
     598                                cout << "--- Leaving scope " << tables->scope << " containing" << std::endl;
     599                                dump( tables->idTable, cout );
     600                                dump( tables->typeTable, cout );
     601                                dump( tables->structTable, cout );
     602                                dump( tables->enumTable, cout );
     603                                dump( tables->unionTable, cout );
     604                                dump( tables->traitTable, cout );
    594605                        }
    595606
Note: See TracChangeset for help on using the changeset viewer.