Changeset 6635c74 for src


Ignore:
Timestamp:
Mar 7, 2016, 1:37:42 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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:
4e284ea6
Parents:
2e60a1a
Message:

Switched GenPoly::Pass1.adapters over to non-copying ScopedMap? from copying stack of std::map

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r2e60a1a r6635c74  
    2626#include "PolyMutator.h"
    2727#include "FindFunction.h"
     28#include "ScopedMap.h"
    2829#include "ScrubTyVars.h"
    2930
     
    112113                        ObjectDecl *makeTemporary( Type *type );
    113114
    114                         typedef std::map< std::string, DeclarationWithType *> AdapterMap;
    115115                        std::map< std::string, DeclarationWithType *> assignOps;
    116116                        ResolvExpr::TypeMap< DeclarationWithType > scopedAssignOps;
    117                         std::stack< AdapterMap > adapters;
     117                        ScopedMap< std::string, DeclarationWithType* > adapters;
    118118                        DeclarationWithType *retval;
    119119                        bool useRetval;
     
    448448                }
    449449
    450                 Pass1::Pass1() : useRetval( false ), tempNamer( "_temp" ) {
    451                         adapters.push(AdapterMap());
    452                 }
     450                Pass1::Pass1() : useRetval( false ), tempNamer( "_temp" ) {}
    453451
    454452                /// Returns T if the given declaration is (*?=?)(T *, T) for some TypeInstType T (return not checked, but maybe should be), NULL otherwise
     
    553551                                } // for
    554552
    555                                 AdapterMap & adapters = Pass1::adapters.top();
    556553                                for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
    557554                                        std::string mangleName = mangleAdapterName( *funType, scopeTyVars );
     
    975972                                        mangleName += makePolyMonoSuffix( originalFunction, exprTyVars );
    976973
    977                                         AdapterMap & adapters = Pass1::adapters.top();
    978                                         AdapterMap::iterator adapter = adapters.find( mangleName );
     974                                        typedef ScopedMap< std::string, DeclarationWithType* >::iterator AdapterIter;
     975                                        AdapterIter adapter = adapters.find( mangleName );
    979976                                        if ( adapter == adapters.end() ) {
    980977                                                // adapter has not been created yet in the current scope, so define it
    981978                                                FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars );
    982                                                 adapter = adapters.insert( adapters.begin(), std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) );
     979                                                std::pair< AdapterIter, bool > answer = adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) );
     980                                                adapter = answer.first;
    983981                                                stmtsToAdd.push_back( new DeclStmt( noLabels, newAdapter ) );
    984982                                        } // if
     
    13591357
    13601358                void Pass1::doBeginScope() {
    1361                         // push a copy of the current map
    1362                         adapters.push(adapters.top());
     1359                        adapters.beginScope();
    13631360                        scopedAssignOps.beginScope();
    13641361                }
    13651362
    13661363                void Pass1::doEndScope() {
    1367                         adapters.pop();
     1364                        adapters.endScope();
    13681365                        scopedAssignOps.endScope();
    13691366                }
Note: See TracChangeset for help on using the changeset viewer.