Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r8ca3a72 rd7dc824  
    6262namespace GenPoly {
    6363        namespace {
     64                const std::list<Label> noLabels;
     65
    6466                FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars );
    6567
     
    101103                        void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    102104                        /// wraps a function application with a new temporary for the out-parameter return value
    103                         Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg );
     105                        Expression *addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg );
    104106                        /// Replaces all the type parameters of a generic type with their concrete equivalents under the current environment
    105107                        void replaceParametersWithConcrete( ApplicationExpr *appExpr, std::list< Expression* >& params );
     
    108110                        Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true );
    109111                        /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value
    110                         Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *polyType, std::list< Expression *>::iterator &arg );
     112                        Expression *addDynRetParam( ApplicationExpr *appExpr, Type *polyType, std::list< Expression *>::iterator &arg );
    111113                        Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    112114                        void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars );
     
    134136                  public:
    135137                        template< typename DeclClass >
    136                         DeclClass *handleDecl( DeclClass *decl, Type *type );
     138                        DeclClass *handleDecl( DeclClass *decl );
    137139                        template< typename AggDecl >
    138140                        AggDecl * handleAggDecl( AggDecl * aggDecl );
     
    663665                }
    664666
    665                 Expression *Pass1::addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ) {
     667                Expression *Pass1::addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg ) {
    666668                        // Create temporary to hold return value of polymorphic function and produce that temporary as a result
    667669                        // using a comma expression.
     
    726728                }
    727729
    728                 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *dynType, std::list< Expression *>::iterator &arg ) {
     730                Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, Type *dynType, std::list< Expression *>::iterator &arg ) {
    729731                        assert( env );
    730732                        Type *concrete = replaceWithConcrete( appExpr, dynType );
    731733                        // add out-parameter for return value
    732                         return addRetParam( appExpr, function, concrete, arg );
     734                        return addRetParam( appExpr, concrete, arg );
    733735                }
    734736
     
    737739//                      if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
    738740                        if ( isDynRet( function, tyVars ) ) {
    739                                 ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg );
     741                                ret = addRetParam( appExpr, function->get_returnVals().front()->get_type(), arg );
    740742                        } // if
    741743                        std::string mangleName = mangleAdapterName( function, tyVars );
     
    11461148                        if ( dynRetType ) {
    11471149                                Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result();
    1148                                 ret = addDynRetParam( appExpr, function, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType
     1150                                ret = addDynRetParam( appExpr, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType
    11491151                        } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...?
    11501152                                // xxx - the ! needsAdapter check may be incorrect. It seems there is some situation where an adapter is applied where it shouldn't be, and this fixes it for some cases. More investigation is needed.
     
    12801282
    12811283                template< typename DeclClass >
    1282                 DeclClass * Pass2::handleDecl( DeclClass *decl, Type *type ) {
     1284                DeclClass * Pass2::handleDecl( DeclClass *decl ) {
    12831285                        DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) );
    12841286
     
    12941296
    12951297                DeclarationWithType * Pass2::mutate( FunctionDecl *functionDecl ) {
    1296                         functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl, functionDecl->get_functionType() ) );
     1298                        functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl ) );
    12971299                        FunctionType * ftype = functionDecl->get_functionType();
    12981300                        if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) {
     
    13191321
    13201322                ObjectDecl * Pass2::mutate( ObjectDecl *objectDecl ) {
    1321                         return handleDecl( objectDecl, objectDecl->get_type() );
     1323                        return handleDecl( objectDecl );
    13221324                }
    13231325
     
    13421344                        addToTyVarMap( typeDecl, scopeTyVars );
    13431345                        if ( typeDecl->get_base() ) {
    1344                                 return handleDecl( typeDecl, typeDecl->get_base() );
     1346                                return handleDecl( typeDecl );
    13451347                        } else {
    13461348                                return Parent::mutate( typeDecl );
     
    13491351
    13501352                TypedefDecl * Pass2::mutate( TypedefDecl *typedefDecl ) {
    1351                         return handleDecl( typedefDecl, typedefDecl->get_base() );
     1353                        return handleDecl( typedefDecl );
    13521354                }
    13531355
Note: See TracChangeset for help on using the changeset viewer.