Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r62e5546 r8c49c0e  
    6464
    6565                /// Adds layout-generation functions to polymorphic types
    66                 class LayoutFunctionBuilder final : public DeclMutator {
     66                class LayoutFunctionBuilder : public DeclMutator {
    6767                        unsigned int functionNesting;  // current level of nested functions
    6868                public:
    6969                        LayoutFunctionBuilder() : functionNesting( 0 ) {}
    7070
    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;
     71                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl );
     72                        virtual Declaration *mutate( StructDecl *structDecl );
     73                        virtual Declaration *mutate( UnionDecl *unionDecl );
    7574                };
    7675
    7776                /// 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
    78                 class Pass1 final : public PolyMutator {
     77                class Pass1 : public PolyMutator {
    7978                  public:
    8079                        Pass1();
    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;
     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();
    9693                  private:
    9794                        /// Pass the extra type parameters from polymorphic generic arguments or return types into a function application
     
    113110                        void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars );
    114111                        /// Stores assignment operators from assertion list in local map of assignment operations
    115                         void findTypeOps( const std::list< TypeDecl *> &forall );
     112                        void findTypeOps( const Type::ForallList &forall );
    116113                        void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars );
    117114                        FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars );
     
    138135                /// * Moves polymorphic returns in function types to pointer-type parameters
    139136                /// * adds type size and assertion parameters to parameter lists
    140                 class Pass2 final : public PolyMutator {
     137                class Pass2 : public PolyMutator {
    141138                  public:
    142139                        template< typename DeclClass >
    143140                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    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;
     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 );
    152147
    153148                  private:
     
    161156                /// * Calculates polymorphic offsetof expressions from offset array
    162157                /// * Inserts dynamic calculation of polymorphic type layouts where needed
    163                 class PolyGenericCalculator final : public PolyMutator {
     158                class PolyGenericCalculator : public PolyMutator {
    164159                public:
    165160                        typedef PolyMutator Parent;
     
    168163                        template< typename DeclClass >
    169164                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    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;
     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();
    185180
    186181                private:
     
    202197
    203198                /// 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
    204                 class Pass3 final : public PolyMutator {
     199                class Pass3 : public PolyMutator {
    205200                  public:
    206201                        template< typename DeclClass >
    207202                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    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;
     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 );
    216209                  private:
    217210                };
     
    619612                }
    620613
    621                 void Pass1::findTypeOps( const std::list< TypeDecl *> &forall ) {
     614                void Pass1::findTypeOps( const Type::ForallList &forall ) {
    622615                        // what if a nested function uses an assignment operator?
    623616                        // assignOps.clear();
    624                         for ( std::list< TypeDecl *>::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     617                        for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
    625618                                for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    626619                                        std::string typeName;
     
    687680                                std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    688681                                std::list< FunctionType *> functions;
    689                                 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     682                                for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    690683                                        for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    691684                                                findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter );
     
    789782
    790783                        // add size/align for generic types to parameter list
    791                         if ( appExpr->get_function()->get_results().empty() ) return;
    792                         FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() );
     784                        if ( ! appExpr->get_function()->has_result() ) return;
     785                        FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() );
    793786                        assert( funcType );
    794787
     
    806799                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
    807800                                VariableExpr *fnArgBase = getBaseVar( *fnArg );
    808                                 if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;
    809                                 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), arg, exprTyVars, seenTypes );
     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 );
    810803                        }
    811804                }
     
    897890                        Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
    898891                        appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) );
    899                         appExpr->set_function( new NameExpr( adapterName ) );
     892                        appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr
    900893
    901894                        return ret;
     
    903896
    904897                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    905                         assert( ! arg->get_results().empty() );
     898                        assert( arg->has_result() );
    906899                        if ( isPolyType( param, exprTyVars ) ) {
    907                                 if ( isPolyType( arg->get_results().front() ) ) {
     900                                if ( isPolyType( arg->get_result() ) ) {
    908901                                        // if the argument's type is polymorphic, we don't need to box again!
    909902                                        return;
    910                                 } else if ( arg->get_results().front()->get_isLvalue() ) {
     903                                } else if ( arg->get_result()->get_isLvalue() ) {
    911904                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
    912905                                        // xxx - need to test that this code is still reachable
     
    953946                void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
    954947                        std::list< Expression *>::iterator cur = arg;
    955                         for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     948                        for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    956949                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    957950                                        InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() );
     
    994987                                        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    995988                                        deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );
    996                                         deref->get_results().push_back( arg->get_type()->clone() );
     989                                        deref->set_result( arg->get_type()->clone() );
    997990                                        return deref;
    998991                                } // if
     
    10201013                        Statement *bodyStmt;
    10211014
    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();
     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();
    10251018                        for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) {
    10261019                                assert( tyArg != realType->get_forall().end() );
     
    10711064                        std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    10721065                        std::list< FunctionType *> functions;
    1073                         for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     1066                        for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    10741067                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    10751068                                        findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter );
     
    11311124                        } // if
    11321125                        addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) );
    1133                         addAssign->get_results().front() = appExpr->get_results().front()->clone();
     1126                        addAssign->set_result( appExpr->get_result()->clone() );
    11341127                        if ( appExpr->get_env() ) {
    11351128                                addAssign->set_env( appExpr->get_env() );
     
    11451138                                if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
    11461139                                        if ( varExpr->get_var()->get_name() == "?[?]" ) {
    1147                                                 assert( ! appExpr->get_results().empty() );
     1140                                                assert( appExpr->has_result() );
    11481141                                                assert( appExpr->get_args().size() == 2 );
    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 );
     1142                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
     1143                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
    11511144                                                assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
    11521145                                                UntypedExpr *ret = 0;
     
    11681161                                                } // if
    11691162                                                if ( baseType1 || baseType2 ) {
    1170                                                         ret->get_results().push_front( appExpr->get_results().front()->clone() );
     1163                                                        ret->set_result( appExpr->get_result()->clone() );
    11711164                                                        if ( appExpr->get_env() ) {
    11721165                                                                ret->set_env( appExpr->get_env() );
     
    11781171                                                } // if
    11791172                                        } else if ( varExpr->get_var()->get_name() == "*?" ) {
    1180                                                 assert( ! appExpr->get_results().empty() );
     1173                                                assert( appExpr->has_result() );
    11811174                                                assert( ! appExpr->get_args().empty() );
    1182                                                 if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1175                                                if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
    11831176                                                        Expression *ret = appExpr->get_args().front();
    1184                                                         delete ret->get_results().front();
    1185                                                         ret->get_results().front() = appExpr->get_results().front()->clone();
     1177                                                        delete ret->get_result();
     1178                                                        ret->set_result( appExpr->get_result()->clone() );
    11861179                                                        if ( appExpr->get_env() ) {
    11871180                                                                ret->set_env( appExpr->get_env() );
     
    11931186                                                } // if
    11941187                                        } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) {
    1195                                                 assert( ! appExpr->get_results().empty() );
     1188                                                assert( appExpr->has_result() );
    11961189                                                assert( appExpr->get_args().size() == 1 );
    1197                                                 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
    1198                                                         Type *tempType = appExpr->get_results().front()->clone();
     1190                                                if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
     1191                                                        Type *tempType = appExpr->get_result()->clone();
    11991192                                                        if ( env ) {
    12001193                                                                env->apply( tempType );
     
    12131206                                                } // if
    12141207                                        } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) {
    1215                                                 assert( ! appExpr->get_results().empty() );
     1208                                                assert( appExpr->has_result() );
    12161209                                                assert( appExpr->get_args().size() == 1 );
    1217                                                 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1210                                                if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
    12181211                                                        return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" );
    12191212                                                } // if
    12201213                                        } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) {
    1221                                                 assert( ! appExpr->get_results().empty() );
     1214                                                assert( appExpr->has_result() );
    12221215                                                assert( appExpr->get_args().size() == 2 );
    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 );
     1216                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
     1217                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
    12251218                                                if ( baseType1 && baseType2 ) {
    12261219                                                        UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) );
    12271220                                                        divide->get_args().push_back( appExpr );
    12281221                                                        divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) );
    1229                                                         divide->get_results().push_front( appExpr->get_results().front()->clone() );
     1222                                                        divide->set_result( appExpr->get_result()->clone() );
    12301223                                                        if ( appExpr->get_env() ) {
    12311224                                                                divide->set_env( appExpr->get_env() );
     
    12451238                                                } // if
    12461239                                        } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) {
    1247                                                 assert( ! appExpr->get_results().empty() );
     1240                                                assert( appExpr->has_result() );
    12481241                                                assert( appExpr->get_args().size() == 2 );
    1249                                                 Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env );
     1242                                                Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env );
    12501243                                                if ( baseType ) {
    12511244                                                        UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) );
     
    12731266                        useRetval = oldUseRetval;
    12741267
    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 );
     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() );
    12801271
    12811272                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    13151306
    13161307                Expression *Pass1::mutate( UntypedExpr *expr ) {
    1317                         if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
     1308                        if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
    13181309                                if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13191310                                        if ( name->get_name() == "*?" ) {
     
    13291320
    13301321                Expression *Pass1::mutate( AddressExpr *addrExpr ) {
    1331                         assert( ! addrExpr->get_arg()->get_results().empty() );
     1322                        assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );
    13321323
    13331324                        bool needs = false;
    13341325                        if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) {
    1335                                 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
     1326                                if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
    13361327                                        if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13371328                                                if ( name->get_name() == "*?" ) {
    13381329                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    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 );
     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() );
    13441333                                                                needs = needsAdapter( function, scopeTyVars );
    13451334                                                        } // if
     
    13501339                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    13511340                        // out of the if condition.
    1352                         bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
     1341                        bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
    13531342                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    13541343                        if ( polytype || needs ) {
    13551344                                Expression *ret = addrExpr->get_arg();
    1356                                 delete ret->get_results().front();
    1357                                 ret->get_results().front() = addrExpr->get_results().front()->clone();
     1345                                delete ret->get_result();
     1346                                ret->set_result( addrExpr->get_result()->clone() );
    13581347                                addrExpr->set_arg( 0 );
    13591348                                delete addrExpr;
     
    13931382                Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
    13941383                        if ( retval && returnStmt->get_expr() ) {
    1395                                 assert( ! returnStmt->get_expr()->get_results().empty() );
     1384                                assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );
    13961385                                // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.
    13971386                                // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     
    14271416                                        // find each of its needed secondary assignment operators
    14281417                                        std::list< Expression* > &tyParams = refType->get_parameters();
    1429                                         std::list< TypeDecl* > &forallParams = functionDecl->get_type()->get_forall();
     1418                                        Type::ForallList &forallParams = functionDecl->get_type()->get_forall();
    14301419                                        std::list< Expression* >::const_iterator tyIt = tyParams.begin();
    1431                                         std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin();
     1420                                        Type::ForallList::const_iterator forallIt = forallParams.begin();
    14321421                                        for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) {
    14331422                                                // Add appropriate mapping to assignment expression environment
     
    14731462                                // replace return statement with appropriate assignment to out parameter
    14741463                                Expression *retParm = new NameExpr( retval->get_name() );
    1475                                 retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
     1464                                retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
    14761465                                assignExpr->get_args().push_back( retParm );
    14771466                                assignExpr->get_args().push_back( returnStmt->get_expr() );
     
    16031592                        ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0,
    16041593                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
    1605                         for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
     1594                        for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
    16061595                                ObjectDecl *sizeParm, *alignParm;
    16071596                                // add all size and alignment parameters to parameter list
Note: See TracChangeset for help on using the changeset viewer.