Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rbdf1954 re56cfdb0  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Nov 24 15:59:33 2015
    13 // Update Count     : 169
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Nov 19 17:40:51 2015
     13// Update Count     : 133
    1414//
    1515
     
    142142
    143143        namespace {
    144                 std::string makePolyMonoSuffix( FunctionType * function, const TyVarMap &tyVars ) {
    145                         std::stringstream name;
    146 
    147                         // if the return type or a parameter type involved polymorphic types, then the adapter will need
    148                         // to take those polymorphic types as pointers. Therefore, there can be two different functions
    149                         // with the same mangled name, so we need to further mangle the names.
    150                         if ( isPolyRet( function, tyVars ) ) {
    151                                 name << "P";
    152                         } else {
    153                                 name << "M";
    154                         }
    155                         name << "_";
    156                         std::list< DeclarationWithType *> &paramList = function->get_parameters();
    157                         for ( std::list< DeclarationWithType *>::iterator arg = paramList.begin(); arg != paramList.end(); ++arg ) {
    158                                 if ( isPolyObj( (*arg)->get_type(), tyVars ) ) {
    159                                         name << "P";
    160                                 } else {
    161                                         name << "M";                           
    162                                 }
    163                         } // for
    164                         return name.str();
    165                 }
    166 
    167                 std::string mangleAdapterName( FunctionType * function, const TyVarMap &tyVars ) {
    168                         return SymTab::Mangler::mangle( function ) + makePolyMonoSuffix( function, tyVars );
    169                 }
    170 
    171144                std::string makeAdapterName( const std::string &mangleName ) {
    172145                        return "_adapter" + mangleName;
     
    244217                                AdapterMap & adapters = Pass1::adapters.top();
    245218                                for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
    246                                         std::string mangleName = mangleAdapterName( *funType, scopeTyVars );
     219                                        std::string mangleName = SymTab::Mangler::mangle( *funType );
     220                                        if ( isPolyRet( *funType, scopeTyVars ) ) {
     221                                                // if the return type involved polymorphic types, then the adapter will need to take those
     222                                                // polymorphic types as pointers. Therefore, there can be two different functions with the same
     223                                                // mangled name, so we need the mangled names to be different.
     224                                                mangleName += "polyret_";
     225                                        } // if
    247226                                        if ( adapters.find( mangleName ) == adapters.end() ) {
    248227                                                std::string adapterName = makeAdapterName( mangleName );
     
    368347                                ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg );
    369348                        } // if
    370                         std::string mangleName = mangleAdapterName( function, tyVars );
     349                        std::string mangleName = SymTab::Mangler::mangle( function );
     350                        if ( isPolyRet( function, tyVars ) ) {
     351                                mangleName += "polyret_";
     352                        } // if
    371353                        std::string adapterName = makeAdapterName( mangleName );
    372354
     
    583565                                        assert( env );
    584566                                        env->apply( realFunction );
    585                                         mangleName = SymTab::Mangler::mangle( realFunction );
    586                                         mangleName += makePolyMonoSuffix( originalFunction, exprTyVars );
     567                                        mangleName = SymTab::Mangler::mangle( realFunction );
     568
     569                                        if ( isPolyRet( originalFunction, exprTyVars ) ) {
     570                                                mangleName += "polyret_";
     571                                        } // if
    587572
    588573                                        AdapterMap & adapters = Pass1::adapters.top();
     
    915900
    916901                void Pass1::doBeginScope() {
    917                         // push a copy of the current map
     902                        // actually, maybe this could (should?) push
     903                        // a copy of the current map
    918904                        adapters.push(adapters.top());
    919905                }
     
    937923                        std::set< std::string > adaptersDone;
    938924                        for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
    939                                 std::string mangleName = mangleAdapterName( *funType, scopeTyVars );
     925                                std::string mangleName = SymTab::Mangler::mangle( *funType );
     926                                if ( isPolyRet( *funType, scopeTyVars ) ) {
     927                                        mangleName += "polyret_";
     928                                } // if
    940929                                if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
    941930                                        std::string adapterName = makeAdapterName( mangleName );
Note: See TracChangeset for help on using the changeset viewer.