Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r8c49c0e r62e5546  
    6464
    6565                /// Adds layout-generation functions to polymorphic types
    66                 class LayoutFunctionBuilder : public DeclMutator {
     66                class LayoutFunctionBuilder final : public DeclMutator {
    6767                        unsigned int functionNesting;  // current level of nested functions
    6868                public:
    6969                        LayoutFunctionBuilder() : functionNesting( 0 ) {}
    7070
    71                         virtual DeclarationWithType *mutate( FunctionDecl *functionDecl );
    72                         virtual Declaration *mutate( StructDecl *structDecl );
    73                         virtual Declaration *mutate( UnionDecl *unionDecl );
     71                        using DeclMutator::mutate;
     72                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
     73                        virtual Declaration *mutate( StructDecl *structDecl ) override;
     74                        virtual Declaration *mutate( UnionDecl *unionDecl ) override;
    7475                };
    7576
    7677                /// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call
    77                 class Pass1 : public PolyMutator {
     78                class Pass1 final : public PolyMutator {
    7879                  public:
    7980                        Pass1();
    80                         virtual Expression *mutate( ApplicationExpr *appExpr );
    81                         virtual Expression *mutate( AddressExpr *addrExpr );
    82                         virtual Expression *mutate( UntypedExpr *expr );
    83                         virtual DeclarationWithType* mutate( FunctionDecl *functionDecl );
    84                         virtual TypeDecl *mutate( TypeDecl *typeDecl );
    85                         virtual Expression *mutate( CommaExpr *commaExpr );
    86                         virtual Expression *mutate( ConditionalExpr *condExpr );
    87                         virtual Statement * mutate( ReturnStmt *returnStmt );
    88                         virtual Type *mutate( PointerType *pointerType );
    89                         virtual Type * mutate( FunctionType *functionType );
    90 
    91                         virtual void doBeginScope();
    92                         virtual void doEndScope();
     81
     82                        using PolyMutator::mutate;
     83                        virtual Expression *mutate( ApplicationExpr *appExpr ) override;
     84                        virtual Expression *mutate( AddressExpr *addrExpr ) override;
     85                        virtual Expression *mutate( UntypedExpr *expr ) override;
     86                        virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ) override;
     87                        virtual TypeDecl *mutate( TypeDecl *typeDecl ) override;
     88                        virtual Expression *mutate( CommaExpr *commaExpr ) override;
     89                        virtual Expression *mutate( ConditionalExpr *condExpr ) override;
     90                        virtual Statement * mutate( ReturnStmt *returnStmt ) override;
     91                        virtual Type *mutate( PointerType *pointerType ) override;
     92                        virtual Type * mutate( FunctionType *functionType ) override;
     93
     94                        virtual void doBeginScope() override;
     95                        virtual void doEndScope() override;
    9396                  private:
    9497                        /// Pass the extra type parameters from polymorphic generic arguments or return types into a function application
     
    110113                        void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars );
    111114                        /// Stores assignment operators from assertion list in local map of assignment operations
    112                         void findTypeOps( const Type::ForallList &forall );
     115                        void findTypeOps( const std::list< TypeDecl *> &forall );
    113116                        void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars );
    114117                        FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars );
     
    135138                /// * Moves polymorphic returns in function types to pointer-type parameters
    136139                /// * adds type size and assertion parameters to parameter lists
    137                 class Pass2 : public PolyMutator {
     140                class Pass2 final : public PolyMutator {
    138141                  public:
    139142                        template< typename DeclClass >
    140143                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    141                         virtual DeclarationWithType *mutate( FunctionDecl *functionDecl );
    142                         virtual ObjectDecl *mutate( ObjectDecl *objectDecl );
    143                         virtual TypeDecl *mutate( TypeDecl *typeDecl );
    144                         virtual TypedefDecl *mutate( TypedefDecl *typedefDecl );
    145                         virtual Type *mutate( PointerType *pointerType );
    146                         virtual Type *mutate( FunctionType *funcType );
     144
     145                        using PolyMutator::mutate;
     146                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
     147                        virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override;
     148                        virtual TypeDecl *mutate( TypeDecl *typeDecl ) override;
     149                        virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ) override;
     150                        virtual Type *mutate( PointerType *pointerType ) override;
     151                        virtual Type *mutate( FunctionType *funcType ) override;
    147152
    148153                  private:
     
    156161                /// * Calculates polymorphic offsetof expressions from offset array
    157162                /// * Inserts dynamic calculation of polymorphic type layouts where needed
    158                 class PolyGenericCalculator : public PolyMutator {
     163                class PolyGenericCalculator final : public PolyMutator {
    159164                public:
    160165                        typedef PolyMutator Parent;
     
    163168                        template< typename DeclClass >
    164169                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    165                         virtual DeclarationWithType *mutate( FunctionDecl *functionDecl );
    166                         virtual ObjectDecl *mutate( ObjectDecl *objectDecl );
    167                         virtual TypedefDecl *mutate( TypedefDecl *objectDecl );
    168                         virtual TypeDecl *mutate( TypeDecl *objectDecl );
    169                         virtual Statement *mutate( DeclStmt *declStmt );
    170                         virtual Type *mutate( PointerType *pointerType );
    171                         virtual Type *mutate( FunctionType *funcType );
    172                         virtual Expression *mutate( MemberExpr *memberExpr );
    173                         virtual Expression *mutate( SizeofExpr *sizeofExpr );
    174                         virtual Expression *mutate( AlignofExpr *alignofExpr );
    175                         virtual Expression *mutate( OffsetofExpr *offsetofExpr );
    176                         virtual Expression *mutate( OffsetPackExpr *offsetPackExpr );
    177 
    178                         virtual void doBeginScope();
    179                         virtual void doEndScope();
     170                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
     171                        virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override;
     172                        virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override;
     173                        virtual TypeDecl *mutate( TypeDecl *objectDecl ) override;
     174                        virtual Statement *mutate( DeclStmt *declStmt ) override;
     175                        virtual Type *mutate( PointerType *pointerType ) override;
     176                        virtual Type *mutate( FunctionType *funcType ) override;
     177                        virtual Expression *mutate( MemberExpr *memberExpr ) override;
     178                        virtual Expression *mutate( SizeofExpr *sizeofExpr ) override;
     179                        virtual Expression *mutate( AlignofExpr *alignofExpr ) override;
     180                        virtual Expression *mutate( OffsetofExpr *offsetofExpr ) override;
     181                        virtual Expression *mutate( OffsetPackExpr *offsetPackExpr ) override;
     182
     183                        virtual void doBeginScope() override;
     184                        virtual void doEndScope() override;
    180185
    181186                private:
     
    197202
    198203                /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable
    199                 class Pass3 : public PolyMutator {
     204                class Pass3 final : public PolyMutator {
    200205                  public:
    201206                        template< typename DeclClass >
    202207                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    203                         virtual DeclarationWithType *mutate( FunctionDecl *functionDecl );
    204                         virtual ObjectDecl *mutate( ObjectDecl *objectDecl );
    205                         virtual TypedefDecl *mutate( TypedefDecl *objectDecl );
    206                         virtual TypeDecl *mutate( TypeDecl *objectDecl );
    207                         virtual Type *mutate( PointerType *pointerType );
    208                         virtual Type *mutate( FunctionType *funcType );
     208
     209                        using PolyMutator::mutate;
     210                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
     211                        virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override;
     212                        virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override;
     213                        virtual TypeDecl *mutate( TypeDecl *objectDecl ) override;
     214                        virtual Type *mutate( PointerType *pointerType ) override;
     215                        virtual Type *mutate( FunctionType *funcType ) override;
    209216                  private:
    210217                };
     
    612619                }
    613620
    614                 void Pass1::findTypeOps( const Type::ForallList &forall ) {
     621                void Pass1::findTypeOps( const std::list< TypeDecl *> &forall ) {
    615622                        // what if a nested function uses an assignment operator?
    616623                        // assignOps.clear();
    617                         for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     624                        for ( std::list< TypeDecl *>::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
    618625                                for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    619626                                        std::string typeName;
     
    680687                                std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    681688                                std::list< FunctionType *> functions;
    682                                 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     689                                for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    683690                                        for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    684691                                                findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter );
     
    782789
    783790                        // add size/align for generic types to parameter list
    784                         if ( ! appExpr->get_function()->has_result() ) return;
    785                         FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() );
     791                        if ( appExpr->get_function()->get_results().empty() ) return;
     792                        FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() );
    786793                        assert( funcType );
    787794
     
    799806                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
    800807                                VariableExpr *fnArgBase = getBaseVar( *fnArg );
    801                                 if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results
    802                                 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes );
     808                                if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;
     809                                passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), arg, exprTyVars, seenTypes );
    803810                        }
    804811                }
     
    890897                        Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
    891898                        appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) );
    892                         appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr
     899                        appExpr->set_function( new NameExpr( adapterName ) );
    893900
    894901                        return ret;
     
    896903
    897904                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    898                         assert( arg->has_result() );
     905                        assert( ! arg->get_results().empty() );
    899906                        if ( isPolyType( param, exprTyVars ) ) {
    900                                 if ( isPolyType( arg->get_result() ) ) {
     907                                if ( isPolyType( arg->get_results().front() ) ) {
    901908                                        // if the argument's type is polymorphic, we don't need to box again!
    902909                                        return;
    903                                 } else if ( arg->get_result()->get_isLvalue() ) {
     910                                } else if ( arg->get_results().front()->get_isLvalue() ) {
    904911                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
    905912                                        // xxx - need to test that this code is still reachable
     
    946953                void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
    947954                        std::list< Expression *>::iterator cur = arg;
    948                         for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     955                        for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    949956                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    950957                                        InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() );
     
    987994                                        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    988995                                        deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );
    989                                         deref->set_result( arg->get_type()->clone() );
     996                                        deref->get_results().push_back( arg->get_type()->clone() );
    990997                                        return deref;
    991998                                } // if
     
    10131020                        Statement *bodyStmt;
    10141021
    1015                         Type::ForallList::iterator tyArg = realType->get_forall().begin();
    1016                         Type::ForallList::iterator tyParam = adapterType->get_forall().begin();
    1017                         Type::ForallList::iterator realTyParam = adaptee->get_forall().begin();
     1022                        std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin();
     1023                        std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin();
     1024                        std::list< TypeDecl *>::iterator realTyParam = adaptee->get_forall().begin();
    10181025                        for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) {
    10191026                                assert( tyArg != realType->get_forall().end() );
     
    10641071                        std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    10651072                        std::list< FunctionType *> functions;
    1066                         for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     1073                        for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    10671074                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    10681075                                        findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter );
     
    11241131                        } // if
    11251132                        addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) );
    1126                         addAssign->set_result( appExpr->get_result()->clone() );
     1133                        addAssign->get_results().front() = appExpr->get_results().front()->clone();
    11271134                        if ( appExpr->get_env() ) {
    11281135                                addAssign->set_env( appExpr->get_env() );
     
    11381145                                if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
    11391146                                        if ( varExpr->get_var()->get_name() == "?[?]" ) {
    1140                                                 assert( appExpr->has_result() );
     1147                                                assert( ! appExpr->get_results().empty() );
    11411148                                                assert( appExpr->get_args().size() == 2 );
    1142                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
    1143                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
     1149                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
     1150                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
    11441151                                                assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
    11451152                                                UntypedExpr *ret = 0;
     
    11611168                                                } // if
    11621169                                                if ( baseType1 || baseType2 ) {
    1163                                                         ret->set_result( appExpr->get_result()->clone() );
     1170                                                        ret->get_results().push_front( appExpr->get_results().front()->clone() );
    11641171                                                        if ( appExpr->get_env() ) {
    11651172                                                                ret->set_env( appExpr->get_env() );
     
    11711178                                                } // if
    11721179                                        } else if ( varExpr->get_var()->get_name() == "*?" ) {
    1173                                                 assert( appExpr->has_result() );
     1180                                                assert( ! appExpr->get_results().empty() );
    11741181                                                assert( ! appExpr->get_args().empty() );
    1175                                                 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
     1182                                                if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) {
    11761183                                                        Expression *ret = appExpr->get_args().front();
    1177                                                         delete ret->get_result();
    1178                                                         ret->set_result( appExpr->get_result()->clone() );
     1184                                                        delete ret->get_results().front();
     1185                                                        ret->get_results().front() = appExpr->get_results().front()->clone();
    11791186                                                        if ( appExpr->get_env() ) {
    11801187                                                                ret->set_env( appExpr->get_env() );
     
    11861193                                                } // if
    11871194                                        } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) {
    1188                                                 assert( appExpr->has_result() );
     1195                                                assert( ! appExpr->get_results().empty() );
    11891196                                                assert( appExpr->get_args().size() == 1 );
    1190                                                 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
    1191                                                         Type *tempType = appExpr->get_result()->clone();
     1197                                                if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1198                                                        Type *tempType = appExpr->get_results().front()->clone();
    11921199                                                        if ( env ) {
    11931200                                                                env->apply( tempType );
     
    12061213                                                } // if
    12071214                                        } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) {
    1208                                                 assert( appExpr->has_result() );
     1215                                                assert( ! appExpr->get_results().empty() );
    12091216                                                assert( appExpr->get_args().size() == 1 );
    1210                                                 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
     1217                                                if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
    12111218                                                        return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" );
    12121219                                                } // if
    12131220                                        } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) {
    1214                                                 assert( appExpr->has_result() );
     1221                                                assert( ! appExpr->get_results().empty() );
    12151222                                                assert( appExpr->get_args().size() == 2 );
    1216                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
    1217                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
     1223                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
     1224                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
    12181225                                                if ( baseType1 && baseType2 ) {
    12191226                                                        UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) );
    12201227                                                        divide->get_args().push_back( appExpr );
    12211228                                                        divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) );
    1222                                                         divide->set_result( appExpr->get_result()->clone() );
     1229                                                        divide->get_results().push_front( appExpr->get_results().front()->clone() );
    12231230                                                        if ( appExpr->get_env() ) {
    12241231                                                                divide->set_env( appExpr->get_env() );
     
    12381245                                                } // if
    12391246                                        } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) {
    1240                                                 assert( appExpr->has_result() );
     1247                                                assert( ! appExpr->get_results().empty() );
    12411248                                                assert( appExpr->get_args().size() == 2 );
    1242                                                 Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env );
     1249                                                Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env );
    12431250                                                if ( baseType ) {
    12441251                                                        UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) );
     
    12661273                        useRetval = oldUseRetval;
    12671274
    1268                         assert( appExpr->get_function()->has_result() );
    1269                         PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
    1270                         FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
     1275                        assert( ! appExpr->get_function()->get_results().empty() );
     1276                        PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
     1277                        assert( pointer );
     1278                        FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
     1279                        assert( function );
    12711280
    12721281                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    13061315
    13071316                Expression *Pass1::mutate( UntypedExpr *expr ) {
    1308                         if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
     1317                        if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
    13091318                                if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13101319                                        if ( name->get_name() == "*?" ) {
     
    13201329
    13211330                Expression *Pass1::mutate( AddressExpr *addrExpr ) {
    1322                         assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );
     1331                        assert( ! addrExpr->get_arg()->get_results().empty() );
    13231332
    13241333                        bool needs = false;
    13251334                        if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) {
    1326                                 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
     1335                                if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
    13271336                                        if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13281337                                                if ( name->get_name() == "*?" ) {
    13291338                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    1330                                                                 assert( appExpr->get_function()->has_result() );
    1331                                                                 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
    1332                                                                 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
     1339                                                                assert( ! appExpr->get_function()->get_results().empty() );
     1340                                                                PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
     1341                                                                assert( pointer );
     1342                                                                FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
     1343                                                                assert( function );
    13331344                                                                needs = needsAdapter( function, scopeTyVars );
    13341345                                                        } // if
     
    13391350                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    13401351                        // out of the if condition.
    1341                         bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
     1352                        bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
    13421353                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    13431354                        if ( polytype || needs ) {
    13441355                                Expression *ret = addrExpr->get_arg();
    1345                                 delete ret->get_result();
    1346                                 ret->set_result( addrExpr->get_result()->clone() );
     1356                                delete ret->get_results().front();
     1357                                ret->get_results().front() = addrExpr->get_results().front()->clone();
    13471358                                addrExpr->set_arg( 0 );
    13481359                                delete addrExpr;
     
    13821393                Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
    13831394                        if ( retval && returnStmt->get_expr() ) {
    1384                                 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );
     1395                                assert( ! returnStmt->get_expr()->get_results().empty() );
    13851396                                // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.
    13861397                                // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     
    14161427                                        // find each of its needed secondary assignment operators
    14171428                                        std::list< Expression* > &tyParams = refType->get_parameters();
    1418                                         Type::ForallList &forallParams = functionDecl->get_type()->get_forall();
     1429                                        std::list< TypeDecl* > &forallParams = functionDecl->get_type()->get_forall();
    14191430                                        std::list< Expression* >::const_iterator tyIt = tyParams.begin();
    1420                                         Type::ForallList::const_iterator forallIt = forallParams.begin();
     1431                                        std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin();
    14211432                                        for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) {
    14221433                                                // Add appropriate mapping to assignment expression environment
     
    14621473                                // replace return statement with appropriate assignment to out parameter
    14631474                                Expression *retParm = new NameExpr( retval->get_name() );
    1464                                 retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
     1475                                retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
    14651476                                assignExpr->get_args().push_back( retParm );
    14661477                                assignExpr->get_args().push_back( returnStmt->get_expr() );
     
    15921603                        ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0,
    15931604                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
    1594                         for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
     1605                        for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
    15951606                                ObjectDecl *sizeParm, *alignParm;
    15961607                                // add all size and alignment parameters to parameter list
Note: See TracChangeset for help on using the changeset viewer.