Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rea5daeb rf18a711  
    104104                        Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true );
    105105                        /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value
    106                         Expression *addPolyRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg );
     106                        Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg );
    107107                        Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    108108                        void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars );
     
    661661                                // process polymorphic return value
    662662                                retval = 0;
    663                                 if ( isPolyRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
     663                                if ( isDynRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
    664664                                        retval = functionDecl->get_functionType()->get_returnVals().front();
    665665
     
    868868                }
    869869
    870                 Expression *Pass1::addPolyRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg ) {
     870                Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *dynType, std::list< Expression *>::iterator &arg ) {
    871871                        assert( env );
    872                         Type *concrete = replaceWithConcrete( appExpr, polyType );
     872                        Type *concrete = replaceWithConcrete( appExpr, dynType );
    873873                        // add out-parameter for return value
    874874                        return addRetParam( appExpr, function, concrete, arg );
     
    877877                Expression *Pass1::applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
    878878                        Expression *ret = appExpr;
    879                         if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
     879//                      if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
     880                        if ( isDynRet( function, tyVars ) ) {
    880881                                ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg );
    881882                        } // if
     
    968969                        // actually make the adapter type
    969970                        FunctionType *adapter = adaptee->clone();
    970                         if ( ! adapter->get_returnVals().empty() && isPolyType( adapter->get_returnVals().front()->get_type(), tyVars ) ) {
     971//                      if ( ! adapter->get_returnVals().empty() && isPolyType( adapter->get_returnVals().front()->get_type(), tyVars ) ) {
     972                        if ( isDynRet( adapter, tyVars ) ) {
    971973                                makeRetParm( adapter );
    972974                        } // if
     
    10301032                                addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars );
    10311033                                bodyStmt = new ExprStmt( noLabels, adapteeApp );
    1032                         } else if ( isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
     1034//                      } else if ( isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
     1035                        } else if ( isDynType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
    10331036                                // return type T
    10341037                                if ( (*param)->get_name() == "" ) {
     
    12771280                        TyVarMap exprTyVars( (TypeDecl::Kind)-1 );
    12781281                        makeTyVarMap( function, exprTyVars );
    1279                         ReferenceToType *polyRetType = isPolyRet( function );
    1280 
    1281                         if ( polyRetType ) {
    1282                                 ret = addPolyRetParam( appExpr, function, polyRetType, arg );
     1282                        ReferenceToType *dynRetType = isDynRet( function, exprTyVars );
     1283
     1284                        if ( dynRetType ) {
     1285                                ret = addDynRetParam( appExpr, function, dynRetType, arg );
    12831286                        } else if ( needsAdapter( function, scopeTyVars ) ) {
    12841287                                // std::cerr << "needs adapter: ";
     
    12901293                        arg = appExpr->get_args().begin();
    12911294
    1292                         passTypeVars( appExpr, polyRetType, arg, exprTyVars );
     1295                        passTypeVars( appExpr, dynRetType, arg, exprTyVars );
    12931296                        addInferredParams( appExpr, function, arg, exprTyVars );
    12941297
     
    15771580
    15781581                        // move polymorphic return type to parameter list
    1579                         if ( isPolyRet( funcType ) ) {
     1582                        if ( isDynRet( funcType ) ) {
    15801583                                DeclarationWithType *ret = funcType->get_returnVals().front();
    15811584                                ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) );
Note: See TracChangeset for help on using the changeset viewer.