Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r5802a4f rdd0c97b  
    136136                        template< typename DeclClass >
    137137                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    138 
    139                         using PolyMutator::mutate;
     138                        template< typename AggDecl >
     139                        AggDecl * handleAggDecl( AggDecl * aggDecl );
     140
     141                        typedef PolyMutator Parent;
     142                        using Parent::mutate;
    140143                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
    141144                        virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override;
     145                        virtual StructDecl *mutate( StructDecl *structDecl ) override;
     146                        virtual UnionDecl *mutate( UnionDecl *unionDecl ) override;
    142147                        virtual TypeDecl *mutate( TypeDecl *typeDecl ) override;
    143148                        virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ) override;
     
    686691                        for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) {
    687692                                TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param );
    688                                 assert(paramType && "Aggregate parameters should be type expressions");
     693                                assertf(paramType, "Aggregate parameters should be type expressions");
    689694                                paramType->set_type( replaceWithConcrete( appExpr, paramType->get_type(), false ) );
    690695                        }
     
    783788                void Pass1::boxParams( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {
    784789                        for ( std::list< DeclarationWithType *>::const_iterator param = function->get_parameters().begin(); param != function->get_parameters().end(); ++param, ++arg ) {
    785                                 assert( arg != appExpr->get_args().end() );
     790                                assertf( arg != appExpr->get_args().end(), "boxParams: missing argument for param %s to %s in %s", toString( *param ).c_str(), toString( function ).c_str(), toString( appExpr ).c_str() );
    786791                                addCast( *arg, (*param)->get_type(), exprTyVars );
    787792                                boxParam( (*param)->get_type(), *arg, exprTyVars );
     
    11271132                        makeTyVarMap( function, exprTyVars ); // xxx - should this take into account the variables already bound in scopeTyVars (i.e. remove them from exprTyVars?)
    11281133                        ReferenceToType *dynRetType = isDynRet( function, exprTyVars );
    1129                         Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result();// ?: dynRetType; // xxx - is concRetType a good name?
    1130 
     1134
     1135                        // NOTE: addDynRetParam needs to know the actual (generated) return type so it can make a temp variable, so pass the result type from the appExpr
     1136                        // passTypeVars needs to know the program-text return type (i.e. the distinction between _conc_T30 and T3(int))
     1137                        // concRetType may not be a good name in one or both of these places. A more appropriate name change is welcome.
    11311138                        if ( dynRetType ) {
     1139                                Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result();
    11321140                                ret = addDynRetParam( appExpr, function, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType
    11331141                        } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...?
     
    11421150                        arg = appExpr->get_args().begin();
    11431151
     1152                        Type *concRetType = replaceWithConcrete( appExpr, dynRetType );
    11441153                        passTypeVars( appExpr, concRetType, arg, exprTyVars ); // xxx - used to use dynRetType instead of concRetType; this changed so that the correct type paramaters are passed for return types (it should be the concrete type's parameters, not the formal type's)
    11451154                        addInferredParams( appExpr, function, arg, exprTyVars );
     
    12711280                template< typename DeclClass >
    12721281                DeclClass * Pass2::handleDecl( DeclClass *decl, Type *type ) {
    1273                         DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );
     1282                        DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) );
    12741283
    12751284                        return ret;
     
    13051314                }
    13061315
     1316                template< typename AggDecl >
     1317                AggDecl * Pass2::handleAggDecl( AggDecl * aggDecl ) {
     1318                        // prevent tyVars from leaking into containing scope
     1319                        scopeTyVars.beginScope();
     1320                        Parent::mutate( aggDecl );
     1321                        scopeTyVars.endScope();
     1322                        return aggDecl;
     1323                }
     1324
     1325                StructDecl * Pass2::mutate( StructDecl *aggDecl ) {
     1326                        return handleAggDecl( aggDecl );
     1327                }
     1328
     1329                UnionDecl * Pass2::mutate( UnionDecl *aggDecl ) {
     1330                        return handleAggDecl( aggDecl );
     1331                }
     1332
    13071333                TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) {
    13081334                        addToTyVarMap( typeDecl, scopeTyVars );
     
    13101336                                return handleDecl( typeDecl, typeDecl->get_base() );
    13111337                        } else {
    1312                                 return Mutator::mutate( typeDecl );
     1338                                return Parent::mutate( typeDecl );
    13131339                        }
    13141340                }
     
    13221348                        makeTyVarMap( pointerType, scopeTyVars );
    13231349
    1324                         Type *ret = Mutator::mutate( pointerType );
     1350                        Type *ret = Parent::mutate( pointerType );
    13251351
    13261352                        scopeTyVars.endScope();
Note: See TracChangeset for help on using the changeset viewer.