Changes in / [aa8f9df:fd782b2]


Ignore:
Location:
src
Files:
2 added
30 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    raa8f9df rfd782b2  
    309309                                                        UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    310310                                                        newExpr->get_args().push_back( *arg );
    311                                                         Type * type = InitTweak::getPointerBase( (*arg)->get_result() );
     311                                                        assert( (*arg)->get_results().size() == 1 );
     312                                                        Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() );
    312313                                                        assert( type );
    313                                                         newExpr->set_result( type->clone() );
     314                                                        newExpr->get_results().push_back( type->clone() );
    314315                                                        *arg = newExpr;
    315316                                                } // if
     
    526527                extension( castExpr );
    527528                output << "(";
    528                 if ( castExpr->get_result()->isVoid() ) {
     529                if ( castExpr->get_results().empty() ) {
    529530                        output << "(void)" ;
    530                 } else if ( ! castExpr->get_result()->get_isLvalue() ) {
     531                } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
    531532                        // at least one result type of cast, but not an lvalue
    532533                        output << "(";
    533                         output << genType( castExpr->get_result(), "" );
     534                        output << genType( castExpr->get_results().front(), "" );
    534535                        output << ")";
    535536                } else {
  • src/ControlStruct/Mutate.cc

    raa8f9df rfd782b2  
    2323#include "MLEMutator.h"
    2424#include "ForExprMutator.h"
     25#include "LabelTypeChecker.h"
    2526//#include "ExceptMutator.h"
    2627
     
    4041
    4142                //ExceptMutator exc;
     43                // LabelTypeChecker lbl;
    4244
    4345                mutateAll( translationUnit, formut );
    4446                acceptAll( translationUnit, lfix );
    4547                //mutateAll( translationUnit, exc );
     48                //acceptAll( translationUnit, lbl );
    4649        }
    4750} // namespace CodeGen
  • src/ControlStruct/module.mk

    raa8f9df rfd782b2  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk --
     8## module.mk -- 
    99##
    1010## Author           : Richard C. Bilson
     
    1919        ControlStruct/MLEMutator.cc \
    2020        ControlStruct/Mutate.cc \
    21         ControlStruct/ForExprMutator.cc
     21        ControlStruct/ForExprMutator.cc \
     22        ControlStruct/LabelTypeChecker.cc
    2223
  • src/GenPoly/Box.cc

    raa8f9df rfd782b2  
    782782
    783783                        // 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() );
     784                        if ( appExpr->get_function()->get_results().empty() ) return;
     785                        FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() );
    786786                        assert( funcType );
    787787
     
    799799                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
    800800                                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 );
     801                                if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;
     802                                passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), arg, exprTyVars, seenTypes );
    803803                        }
    804804                }
     
    890890                        Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
    891891                        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
     892                        appExpr->set_function( new NameExpr( adapterName ) );
    893893
    894894                        return ret;
     
    896896
    897897                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    898                         assert( arg->has_result() );
     898                        assert( ! arg->get_results().empty() );
    899899                        if ( isPolyType( param, exprTyVars ) ) {
    900                                 if ( isPolyType( arg->get_result() ) ) {
     900                                if ( isPolyType( arg->get_results().front() ) ) {
    901901                                        // if the argument's type is polymorphic, we don't need to box again!
    902902                                        return;
    903                                 } else if ( arg->get_result()->get_isLvalue() ) {
     903                                } else if ( arg->get_results().front()->get_isLvalue() ) {
    904904                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
    905905                                        // xxx - need to test that this code is still reachable
     
    987987                                        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    988988                                        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() );
     989                                        deref->get_results().push_back( arg->get_type()->clone() );
    990990                                        return deref;
    991991                                } // if
     
    11241124                        } // if
    11251125                        addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) );
    1126                         addAssign->set_result( appExpr->get_result()->clone() );
     1126                        addAssign->get_results().front() = appExpr->get_results().front()->clone();
    11271127                        if ( appExpr->get_env() ) {
    11281128                                addAssign->set_env( appExpr->get_env() );
     
    11381138                                if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
    11391139                                        if ( varExpr->get_var()->get_name() == "?[?]" ) {
    1140                                                 assert( appExpr->has_result() );
     1140                                                assert( ! appExpr->get_results().empty() );
    11411141                                                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 );
     1142                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
     1143                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
    11441144                                                assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
    11451145                                                UntypedExpr *ret = 0;
     
    11611161                                                } // if
    11621162                                                if ( baseType1 || baseType2 ) {
    1163                                                         ret->set_result( appExpr->get_result()->clone() );
     1163                                                        ret->get_results().push_front( appExpr->get_results().front()->clone() );
    11641164                                                        if ( appExpr->get_env() ) {
    11651165                                                                ret->set_env( appExpr->get_env() );
     
    11711171                                                } // if
    11721172                                        } else if ( varExpr->get_var()->get_name() == "*?" ) {
    1173                                                 assert( appExpr->has_result() );
     1173                                                assert( ! appExpr->get_results().empty() );
    11741174                                                assert( ! appExpr->get_args().empty() );
    1175                                                 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
     1175                                                if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) {
    11761176                                                        Expression *ret = appExpr->get_args().front();
    1177                                                         delete ret->get_result();
    1178                                                         ret->set_result( appExpr->get_result()->clone() );
     1177                                                        delete ret->get_results().front();
     1178                                                        ret->get_results().front() = appExpr->get_results().front()->clone();
    11791179                                                        if ( appExpr->get_env() ) {
    11801180                                                                ret->set_env( appExpr->get_env() );
     
    11861186                                                } // if
    11871187                                        } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) {
    1188                                                 assert( appExpr->has_result() );
     1188                                                assert( ! appExpr->get_results().empty() );
    11891189                                                assert( appExpr->get_args().size() == 1 );
    1190                                                 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
    1191                                                         Type *tempType = appExpr->get_result()->clone();
     1190                                                if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1191                                                        Type *tempType = appExpr->get_results().front()->clone();
    11921192                                                        if ( env ) {
    11931193                                                                env->apply( tempType );
     
    12061206                                                } // if
    12071207                                        } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) {
    1208                                                 assert( appExpr->has_result() );
     1208                                                assert( ! appExpr->get_results().empty() );
    12091209                                                assert( appExpr->get_args().size() == 1 );
    1210                                                 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
     1210                                                if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
    12111211                                                        return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" );
    12121212                                                } // if
    12131213                                        } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) {
    1214                                                 assert( appExpr->has_result() );
     1214                                                assert( ! appExpr->get_results().empty() );
    12151215                                                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 );
     1216                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
     1217                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
    12181218                                                if ( baseType1 && baseType2 ) {
    12191219                                                        UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) );
    12201220                                                        divide->get_args().push_back( appExpr );
    12211221                                                        divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) );
    1222                                                         divide->set_result( appExpr->get_result()->clone() );
     1222                                                        divide->get_results().push_front( appExpr->get_results().front()->clone() );
    12231223                                                        if ( appExpr->get_env() ) {
    12241224                                                                divide->set_env( appExpr->get_env() );
     
    12381238                                                } // if
    12391239                                        } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) {
    1240                                                 assert( appExpr->has_result() );
     1240                                                assert( ! appExpr->get_results().empty() );
    12411241                                                assert( appExpr->get_args().size() == 2 );
    1242                                                 Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env );
     1242                                                Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env );
    12431243                                                if ( baseType ) {
    12441244                                                        UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) );
     
    12661266                        useRetval = oldUseRetval;
    12671267
    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() );
     1268                        assert( ! appExpr->get_function()->get_results().empty() );
     1269                        PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
     1270                        assert( pointer );
     1271                        FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
     1272                        assert( function );
    12711273
    12721274                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    13061308
    13071309                Expression *Pass1::mutate( UntypedExpr *expr ) {
    1308                         if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
     1310                        if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
    13091311                                if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13101312                                        if ( name->get_name() == "*?" ) {
     
    13201322
    13211323                Expression *Pass1::mutate( AddressExpr *addrExpr ) {
    1322                         assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );
     1324                        assert( ! addrExpr->get_arg()->get_results().empty() );
    13231325
    13241326                        bool needs = false;
    13251327                        if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) {
    1326                                 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
     1328                                if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
    13271329                                        if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13281330                                                if ( name->get_name() == "*?" ) {
    13291331                                                        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() );
     1332                                                                assert( ! appExpr->get_function()->get_results().empty() );
     1333                                                                PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
     1334                                                                assert( pointer );
     1335                                                                FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
     1336                                                                assert( function );
    13331337                                                                needs = needsAdapter( function, scopeTyVars );
    13341338                                                        } // if
     
    13391343                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    13401344                        // out of the if condition.
    1341                         bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
     1345                        bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
    13421346                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    13431347                        if ( polytype || needs ) {
    13441348                                Expression *ret = addrExpr->get_arg();
    1345                                 delete ret->get_result();
    1346                                 ret->set_result( addrExpr->get_result()->clone() );
     1349                                delete ret->get_results().front();
     1350                                ret->get_results().front() = addrExpr->get_results().front()->clone();
    13471351                                addrExpr->set_arg( 0 );
    13481352                                delete addrExpr;
     
    13821386                Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
    13831387                        if ( retval && returnStmt->get_expr() ) {
    1384                                 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );
     1388                                assert( ! returnStmt->get_expr()->get_results().empty() );
    13851389                                // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.
    13861390                                // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     
    14621466                                // replace return statement with appropriate assignment to out parameter
    14631467                                Expression *retParm = new NameExpr( retval->get_name() );
    1464                                 retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
     1468                                retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
    14651469                                assignExpr->get_args().push_back( retParm );
    14661470                                assignExpr->get_args().push_back( returnStmt->get_expr() );
  • src/GenPoly/Lvalue.cc

    raa8f9df rfd782b2  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Lvalue.cc --
     7// Lvalue.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    4141                  public:
    4242                        Pass1();
    43 
     43 
    4444                        virtual Expression *mutate( ApplicationExpr *appExpr );
    4545                        virtual Statement *mutate( ReturnStmt *appExpr );
     
    9999                        appExpr->get_function()->acceptMutator( *this );
    100100                        mutateAll( appExpr->get_args(), *this );
     101 
     102                        assert( ! appExpr->get_function()->get_results().empty() );
    101103
    102                         PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
    103                         FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     104                        PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
     105                        assert( pointer );
     106                        FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
     107                        assert( function );
    104108
    105109                        Type *funType = isLvalueRet( function );
    106110                        if ( funType && ! isIntrinsicApp( appExpr ) ) {
    107111                                Expression *expr = appExpr;
    108                                 Type *appType = appExpr->get_result();
     112                                Type *appType = appExpr->get_results().front();
    109113                                if ( isPolyType( funType ) && ! isPolyType( appType ) ) {
    110114                                        // make sure cast for polymorphic type is inside dereference
     
    112116                                }
    113117                                UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    114                                 deref->set_result( appType->clone() );
    115                                 appExpr->set_result( new PointerType( Type::Qualifiers(), appType ) );
     118                                deref->get_results().push_back( appType->clone() );
     119                                appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType );
    116120                                deref->get_args().push_back( expr );
    117121                                return deref;
     
    123127                Statement * Pass1::mutate(ReturnStmt *retStmt) {
    124128                        if ( retval && retStmt->get_expr() ) {
    125                                 if ( retStmt->get_expr()->get_result()->get_isLvalue() ) {
     129                                assert( ! retStmt->get_expr()->get_results().empty() );
     130                                if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) {
    126131                                        // ***** Code Removal ***** because casts may be stripped already
    127132
     
    150155                                retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) );
    151156                        } // if
    152 
     157 
    153158                        Visitor::visit( funType );
    154159                }
  • src/GenPoly/Specialize.cc

    raa8f9df rfd782b2  
    147147
    148148        Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) {
    149                 assert( actual->has_result() );
    150                 if ( needsSpecialization( formalType, actual->get_result(), env ) ) {
     149                assert( ! actual->get_results().empty() ); // using front, should have this assert
     150                if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
    151151                        FunctionType *funType;
    152152                        if ( ( funType = getFunctionType( formalType ) ) ) {
     
    171171        void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) {
    172172                // create thunks for the explicit parameters
    173                 assert( appExpr->get_function()->has_result() );
    174                 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
     173                assert( ! appExpr->get_function()->get_results().empty() );
     174                FunctionType *function = getFunctionType( appExpr->get_function()->get_results().front() );
    175175                assert( function );
    176176                std::list< DeclarationWithType* >::iterator formal;
     
    200200        Expression * Specialize::mutate( AddressExpr *addrExpr ) {
    201201                addrExpr->get_arg()->acceptMutator( *this );
    202                 assert( addrExpr->has_result() );
    203                 addrExpr->set_arg( doSpecialization( addrExpr->get_result(), addrExpr->get_arg() ) );
     202                assert( ! addrExpr->get_results().empty() );
     203                addrExpr->set_arg( doSpecialization( addrExpr->get_results().front(), addrExpr->get_arg() ) );
    204204                return addrExpr;
    205205        }
     
    207207        Expression * Specialize::mutate( CastExpr *castExpr ) {
    208208                castExpr->get_arg()->acceptMutator( *this );
    209                 if ( castExpr->get_result()->isVoid() ) {
     209                if ( castExpr->get_results().empty() ) {
    210210                        // can't specialize if we don't have a return value
    211211                        return castExpr;
    212212                }
    213                 Expression *specialized = doSpecialization( castExpr->get_result(), castExpr->get_arg() );
     213                Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() );
    214214                if ( specialized != castExpr->get_arg() ) {
    215215                        // assume here that the specialization incorporates the cast
  • src/InitTweak/FixInit.cc

    raa8f9df rfd782b2  
    391391                                CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
    392392                                // xxx - need to handle tuple arguments
    393                                 assert( arg->has_result() );
    394                                 Type * result = arg->get_result();
     393                                assert( ! arg->get_results().empty() );
     394                                Type * result = arg->get_results().front();
    395395                                if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types
    396396                                // type may involve type variables, so apply type substitution to get temporary variable's actual type
     
    423423                        // level. Trying to pass that environment along.
    424424                        callExpr->set_env( impCpCtorExpr->get_env()->clone() );
    425                         Type * result = appExpr->get_result();
    426                         if ( ! result->isVoid() ) {
    427                                 // need to flatten result type and construct each
     425                        for ( Type * result : appExpr->get_results() ) {
    428426                                result = result->clone();
    429427                                impCpCtorExpr->get_env()->apply( result );
     
    481479                                // know the result type of the assignment is the type of the LHS (minus the pointer), so
    482480                                // add that onto the assignment expression so that later steps have the necessary information
    483                                 assign->set_result( returnDecl->get_type()->clone() );
     481                                assign->add_result( returnDecl->get_type()->clone() );
    484482
    485483                                Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
    486                                 if ( callExpr->get_result()->get_isLvalue() ) {
     484                                if ( callExpr->get_results().front()->get_isLvalue() ) {
    487485                                        // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning
    488486                                        // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the
     
    502500                                        UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
    503501                                        deref->get_args().push_back( retExpr );
    504                                         deref->set_result( resultType );
     502                                        deref->add_result( resultType );
    505503                                        retExpr = deref;
    506504                                } // if
     
    941939                Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) {
    942940                        static UniqueName tempNamer( "_tmp_ctor_expr" );
    943                         assert( ctorExpr->has_result() && ctorExpr->get_result()->size() == 1 );
    944                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );
     941                        assert( ctorExpr->get_results().size() == 1 );
     942                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr );
    945943                        addDeclaration( tmp );
    946944
     
    954952                        assign->get_args().push_back( new VariableExpr( tmp ) );
    955953                        assign->get_args().push_back( firstArg );
    956                         assign->set_result( ctorExpr->get_result()->clone() );
     954                        cloneAll( ctorExpr->get_results(), assign->get_results() );
    957955                        firstArg = assign;
    958956
  • src/InitTweak/InitTweak.cc

    raa8f9df rfd782b2  
    340340                return allofCtorDtor( stmt, []( Expression * callExpr ){
    341341                        if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) {
    342                                 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() );
     342                                assert( ! appExpr->get_function()->get_results().empty() );
     343                                FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() );
    343344                                assert( funcType );
    344345                                return funcType->get_parameters().size() == 1;
  • src/Makefile.in

    raa8f9df rfd782b2  
    104104        ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \
    105105        ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \
     106        ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \
    106107        GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \
    107108        GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \
     
    360361        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    361362        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    362         ControlStruct/ForExprMutator.cc GenPoly/Box.cc \
     363        ControlStruct/ForExprMutator.cc \
     364        ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \
    363365        GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
    364366        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
     
    533535        ControlStruct/$(DEPDIR)/$(am__dirstamp)
    534536ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT):  \
     537        ControlStruct/$(am__dirstamp) \
     538        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     539ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT):  \
    535540        ControlStruct/$(am__dirstamp) \
    536541        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     
    786791        -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT)
    787792        -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT)
     793        -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)
    788794        -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT)
    789795        -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT)
     
    890896@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@
    891897@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelGenerator.Po@am__quote@
     898@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po@am__quote@
    892899@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@
    893900@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@
     
    12041211@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ForExprMutator.obj `if test -f 'ControlStruct/ForExprMutator.cc'; then $(CYGPATH_W) 'ControlStruct/ForExprMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ForExprMutator.cc'; fi`
    12051212
     1213ControlStruct/driver_cfa_cpp-LabelTypeChecker.o: ControlStruct/LabelTypeChecker.cc
     1214@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc
     1215@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po
     1216@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.o' libtool=no @AMDEPBACKSLASH@
     1217@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1218@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc
     1219
     1220ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj: ControlStruct/LabelTypeChecker.cc
     1221@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`
     1222@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po
     1223@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj' libtool=no @AMDEPBACKSLASH@
     1224@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1225@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`
     1226
    12061227GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc
    12071228@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/driver_cfa_cpp-Box.o -MD -MP -MF GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Tpo -c -o GenPoly/driver_cfa_cpp-Box.o `test -f 'GenPoly/Box.cc' || echo '$(srcdir)/'`GenPoly/Box.cc
  • src/ResolvExpr/Alternative.cc

    raa8f9df rfd782b2  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Alternative.cc --
     7// Alternative.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    1212// Last Modified On : Sat May 16 23:54:23 2015
    1313// Update Count     : 2
    14 //
     14// 
    1515
    1616#include "Alternative.h"
     
    5454                        expr->print( os, indent );
    5555                        os << "(types:" << std::endl;
    56                         os << std::string( indent+4, ' ' );
    57                         expr->get_result()->print( os, indent + 4 );
    58                         os << std::endl << ")" << std::endl;
     56                        printAll( expr->get_results(), os, indent + 4 );
     57                        os << ")" << std::endl;
    5958                } else {
    6059                        os << "Null expression!" << std::endl;
  • src/ResolvExpr/AlternativeFinder.cc

    raa8f9df rfd782b2  
    100100                                PruneStruct current( candidate );
    101101                                std::string mangleName;
    102                                 {
    103                                         Type * newType = candidate->expr->get_result()->clone();
     102                                for ( std::list< Type* >::const_iterator retType = candidate->expr->get_results().begin(); retType != candidate->expr->get_results().end(); ++retType ) {
     103                                        Type *newType = (*retType)->clone();
    104104                                        candidate->env.apply( newType );
    105                                         mangleName = SymTab::Mangler::mangle( newType );
     105                                        mangleName += SymTab::Mangler::mangle( newType );
    106106                                        delete newType;
    107107                                }
     
    132132                                if ( ! target->second.isAmbiguous ) {
    133133                                        Alternative &alt = *target->second.candidate;
    134                                         alt.env.applyFree( alt.expr->get_result() );
     134                                        for ( std::list< Type* >::iterator result = alt.expr->get_results().begin(); result != alt.expr->get_results().end(); ++result ) {
     135                                                alt.env.applyFree( *result );
     136                                        }
    135137                                        *out++ = alt;
    136138                                }
    137139                        }
     140
    138141                }
    139142
     
    146149
    147150                void renameTypes( Expression *expr ) {
    148                         expr->get_result()->accept( global_renamer );
     151                        for ( std::list< Type* >::iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) {
     152                                (*i)->accept( global_renamer );
     153                        }
     154                }
     155
     156                // flatten tuple type into list of types
     157                template< typename OutputIterator >
     158                void flatten( Type * type, OutputIterator out ) {
     159                        if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) {
     160                                for ( Type * t : *tupleType ) {
     161                                        flatten( t, out );
     162                                }
     163                        } else {
     164                                *out++ = type;
     165                        }
    149166                }
    150167        }
     
    178195                for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    179196                        if ( adjust ) {
    180                                 adjustExprType( i->expr->get_result(), i->env, indexer );
     197                                adjustExprTypeList( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );
    181198                        }
    182199                }
     
    248265        Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) {
    249266                ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr );
    250                 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     267                PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    251268                FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    252269
     
    265282                                (*actualExpr)->print( std::cerr, 8 );
    266283                                std::cerr << "--- results are" << std::endl;
    267                                 (*actualExpr)->get_result()->print( std::cerr, 8 );
     284                                printAll( (*actualExpr)->get_results(), std::cerr, 8 );
    268285                        )
    269286                        std::list< DeclarationWithType* >::iterator startFormal = formal;
    270287                        Cost actualCost;
    271                         std::list< Type * > flatActualTypes;
    272                         flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) );
    273                         for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) {
    274 
     288                        for ( std::list< Type* >::iterator actualType = (*actualExpr)->get_results().begin(); actualType != (*actualExpr)->get_results().end(); ++actualType ) {
    275289
    276290                                // tuple handling code
     
    385399
    386400                for ( AltList::const_iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) {
    387                         std::list< Type * > flatActualTypes;
    388                         flatten( actualExpr->expr->get_result(), back_inserter( flatActualTypes ) );
    389                         for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType, ++formalType ) {
     401                        std::list< Type* > & actualTypes = actualExpr->expr->get_results();
     402                        for ( std::list< Type* >::iterator actualType = actualTypes.begin(); actualType != actualTypes.end(); ++actualType ) {
    390403                                if ( formalType == formalTypes.end() ) {
    391404                                        // the type of the formal parameter may be a tuple type. To make this easier to work with,
     
    403416                                PRINT(
    404417                                        std::cerr << "formal type is ";
    405                                         (*formalType)->print( std::cerr );
     418                                        (*formal)->get_type()->print( std::cerr );
    406419                                        std::cerr << std::endl << "actual type is ";
    407420                                        (*actualType)->print( std::cerr );
     
    411424                                        return false;
    412425                                }
     426                                ++formalType;
    413427                        }
    414428                }
     
    518532                                //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
    519533                                Expression *varExpr = new VariableExpr( candDecl );
    520                                 delete varExpr->get_result();
    521                                 varExpr->set_result( adjType->clone() );
     534                                deleteAll( varExpr->get_results() );
     535                                varExpr->get_results().clear();
     536                                varExpr->get_results().push_front( adjType->clone() );
    522537                                PRINT(
    523538                                        std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " ";
     
    591606                                PointerType pt( Type::Qualifiers(), v.clone() );
    592607                                UntypedExpr *vexpr = untypedExpr->clone();
    593                                 vexpr->set_result( pt.clone() );
     608                                vexpr->get_results().push_front( pt.clone() );
    594609                                alternatives.push_back( Alternative( vexpr, env, Cost()) );
    595610                                return;
     
    619634                                // check if the type is pointer to function
    620635                                PointerType *pointer;
    621                                 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) {
     636                                if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {
    622637                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    623638                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    655670                                                // check if the type is pointer to function
    656671                                                PointerType *pointer;
    657                                                 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) {
     672                                                if ( funcOp->expr->get_results().size() == 1
     673                                                        && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) {
    658674                                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    659675                                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    680696                        PRINT(
    681697                                ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr );
    682                                 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     698                                PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    683699                                FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    684700                                std::cerr << "Case +++++++++++++" << std::endl;
     
    703719
    704720        bool isLvalue( Expression *expr ) {
    705                 // xxx - recurse into tuples?
    706                 return expr->has_result() && expr->get_result()->get_isLvalue();
     721                for ( std::list< Type* >::const_iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) {
     722                        if ( !(*i)->get_isLvalue() ) return false;
     723                } // for
     724                return true;
    707725        }
    708726
     
    718736
    719737        void AlternativeFinder::visit( CastExpr *castExpr ) {
    720                 Type *& toType = castExpr->get_result();
    721                 toType = resolveTypeof( toType, indexer );
    722                 SymTab::validateType( toType, &indexer );
    723                 adjustExprType( toType, env, indexer );
     738                for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) {
     739                        *i = resolveTypeof( *i, indexer );
     740                        SymTab::validateType( *i, &indexer );
     741                        adjustExprType( *i, env, indexer );
     742                } // for
    724743
    725744                AlternativeFinder finder( indexer, env );
     
    735754                        // that are cast directly.  The candidate is invalid if it has fewer results than there are types to cast
    736755                        // to.
    737                         int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size();
     756                        int discardedValues = (*i).expr->get_results().size() - castExpr->get_results().size();
    738757                        if ( discardedValues < 0 ) continue;
    739                         // xxx - may need to go into tuple types and extract relavent types and use unifyList
     758                        std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin();
     759                        std::advance( candidate_end, castExpr->get_results().size() );
    740760                        // unification run for side-effects
    741                         unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer );
    742                         Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env );
     761                        unifyList( castExpr->get_results().begin(), castExpr->get_results().end(),
     762                                           (*i).expr->get_results().begin(), candidate_end,
     763                                   i->env, needAssertions, haveAssertions, openVars, indexer );
     764                        Cost thisCost = castCostList( (*i).expr->get_results().begin(), candidate_end,
     765                                                                                  castExpr->get_results().begin(), castExpr->get_results().end(),
     766                                                                                  indexer, i->env );
    743767                        if ( thisCost != Cost::infinity ) {
    744768                                // count one safe conversion for each value that is thrown away
     
    763787
    764788                for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) {
    765                         if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) {
    766                                 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    767                         } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) {
    768                                 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     789                        if ( agg->expr->get_results().size() == 1 ) {
     790                                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) {
     791                                        addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     792                                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) {
     793                                        addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     794                                } // if
    769795                        } // if
    770796                } // for
     
    897923                        alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) );
    898924                        for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
    899                                 alternatives.back().expr->set_result( (*i)->get_type()->clone() );
     925                                alternatives.back().expr->get_results().push_back( (*i)->get_type()->clone() );
    900926                        } // for
    901927                } // if
     
    920946                                                        finder.find( attrExpr->get_expr() );
    921947                                                        for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) {
    922                                                                 if ( choice->expr->get_result()->size() == 1 ) {
    923                                                                         resolveAttr(*i, function, choice->expr->get_result(), choice->env );
     948                                                                if ( choice->expr->get_results().size() == 1 ) {
     949                                                                        resolveAttr(*i, function, choice->expr->get_results().front(), choice->env );
    924950                                                                } // fi
    925951                                                        } // for
     
    963989                                        AssertionSet needAssertions, haveAssertions;
    964990                                        Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost );
    965                                         Type* commonType;
    966                                         if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
     991                                        std::list< Type* > commonTypes;
     992                                        if ( unifyList( second->expr->get_results().begin(), second->expr->get_results().end(), third->expr->get_results().begin(), third->expr->get_results().end(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
    967993                                                ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() );
    968                                                 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() );
     994                                                std::list< Type* >::const_iterator original = second->expr->get_results().begin();
     995                                                std::list< Type* >::const_iterator commonType = commonTypes.begin();
     996                                                for ( ; original != second->expr->get_results().end() && commonType != commonTypes.end(); ++original, ++commonType ) {
     997                                                        if ( *commonType ) {
     998                                                                newExpr->get_results().push_back( *commonType );
     999                                                        } else {
     1000                                                                newExpr->get_results().push_back( (*original)->clone() );
     1001                                                        } // if
     1002                                                } // for
    9691003                                                newAlt.expr = newExpr;
    9701004                                                inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
     
    9941028                        TupleExpr *newExpr = new TupleExpr;
    9951029                        makeExprList( *i, newExpr->get_exprs() );
    996                         TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) );
    997                         Type::Qualifiers &qualifiers = tupleType->get_qualifiers();
    998                         for ( Expression * resultExpr : newExpr->get_exprs() ) {
    999                                 Type * type = resultExpr->get_result()->clone();
    1000                                 tupleType->get_types().push_back( type );
    1001                                 qualifiers &= type->get_qualifiers();
     1030                        for ( std::list< Expression* >::const_iterator resultExpr = newExpr->get_exprs().begin(); resultExpr != newExpr->get_exprs().end(); ++resultExpr ) {
     1031                                for ( std::list< Type* >::const_iterator resultType = (*resultExpr)->get_results().begin(); resultType != (*resultExpr)->get_results().end(); ++resultType ) {
     1032                                        newExpr->get_results().push_back( (*resultType)->clone() );
     1033                                } // for
    10021034                        } // for
    1003                         newExpr->set_result( tupleType );
    10041035
    10051036                        TypeEnvironment compositeEnv;
     
    10261057                alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) );
    10271058        }
    1028 
    1029         void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) {
    1030                 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) );
    1031         }
    10321059} // namespace ResolvExpr
    10331060
  • src/ResolvExpr/AlternativeFinder.h

    raa8f9df rfd782b2  
    6868                virtual void visit( ConstructorExpr * ctorExpr );
    6969                virtual void visit( TupleIndexExpr *tupleExpr );
    70                 virtual void visit( TupleAssignExpr *tupleExpr );
    7170                /// Runs a new alternative finder on each element in [begin, end)
    7271                /// and writes each alternative finder to out.
  • src/ResolvExpr/AlternativePrinter.cc

    raa8f9df rfd782b2  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // AlternativePrinter.cc --
     7// AlternativePrinter.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    3333                for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    3434                        os << "Alternative " << count++ << " ==============" << std::endl;
    35                         i->expr->get_result()->print( os );
     35                        printAll( i->expr->get_results(), os );
    3636                        //    i->print( os );
    3737                        os << std::endl;
  • src/ResolvExpr/ResolveTypeof.cc

    raa8f9df rfd782b2  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ResolveTypeof.cc --
     7// ResolveTypeof.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    5858                if ( typeofType->get_expr() ) {
    5959                        Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
    60                         assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() );
    61                         Type *newType = newExpr->get_result();
     60                        assert( newExpr->get_results().size() > 0 );
     61                        Type *newType;
     62                        if ( newExpr->get_results().size() > 1 ) {
     63                                TupleType *tupleType = new TupleType( Type::Qualifiers() );
     64                                cloneAll( newExpr->get_results(), tupleType->get_types() );
     65                                newType = tupleType;
     66                        } else {
     67                                newType = newExpr->get_results().front()->clone();
     68                        } // if
    6269                        delete typeofType;
    6370                        return newType;
  • src/ResolvExpr/Resolver.cc

    raa8f9df rfd782b2  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
    21 #include "typeops.h"
    2221#include "SynTree/Statement.h"
    2322#include "SynTree/Type.h"
     
    6867          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    6968          void fallbackInit( ConstructorInit * ctorInit );
    70                 Type * functionReturn;
     69                std::list< Type * > functionReturn;
    7170                Type *initContext;
    7271                Type *switchType;
     
    156155                        const TypeEnvironment *newEnv = 0;
    157156                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    158                                 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
     157                                if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
    159158                                        if ( newExpr ) {
    160159                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    233232                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    234233                functionDecl->set_type( new_type );
    235                 ValueGuard< Type * > oldFunctionReturn( functionReturn );
    236                 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
     234                std::list< Type * > oldFunctionReturn = functionReturn;
     235                functionReturn.clear();
     236                for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) {
     237                        functionReturn.push_back( (*i)->get_type() );
     238                } // for
    237239                SymTab::Indexer::visit( functionDecl );
     240                functionReturn = oldFunctionReturn;
    238241        }
    239242
     
    333336        void Resolver::visit( ReturnStmt *returnStmt ) {
    334337                if ( returnStmt->get_expr() ) {
    335                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
     338                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
     339                        cloneAll( functionReturn, castExpr->get_results() );
    336340                        Expression *newExpr = findSingleExpression( castExpr, *this );
    337341                        delete castExpr;
     
    378382                                if ( isCharType( at->get_base() ) ) {
    379383                                        // check if the resolved type is char *
    380                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
     384                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
    381385                                                if ( isCharType( pt->get_base() ) ) {
    382386                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
  • src/ResolvExpr/Unify.cc

    raa8f9df rfd782b2  
    588588        }
    589589
    590         // xxx - compute once and store in the FunctionType?
    591         Type * extractResultType( FunctionType * function ) {
    592                 if ( function->get_returnVals().size() == 0 ) {
    593                         return new VoidType( Type::Qualifiers() );
    594                 } else if ( function->get_returnVals().size() == 1 ) {
    595                         return function->get_returnVals().front()->get_type()->clone();
    596                 } else {
    597                         TupleType * tupleType = new TupleType( Type::Qualifiers() );
    598                         for ( DeclarationWithType * decl : function->get_returnVals() ) {
    599                                 tupleType->get_types().push_back( decl->get_type()->clone() );
    600                         } // for
    601                         return tupleType;
    602                 }
    603         }
    604 
    605590} // namespace ResolvExpr
    606591
  • src/ResolvExpr/typeops.h

    raa8f9df rfd782b2  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // typeops.h --
     7// typeops.h -- 
    88//
    99// Author           : Richard C. Bilson
     
    3030                typedef typename InputIterator::value_type SetType;
    3131                typedef typename std::list< typename SetType::value_type > ListType;
    32 
     32 
    3333                if ( begin == end )     {
    3434                        *out++ = ListType();
    3535                        return;
    3636                } // if
    37 
     37 
    3838                InputIterator current = begin;
    3939                begin++;
     
    4141                std::list< ListType > recursiveResult;
    4242                combos( begin, end, back_inserter( recursiveResult ) );
    43 
     43 
    4444                for ( typename std::list< ListType >::const_iterator i = recursiveResult.begin(); i != recursiveResult.end(); ++i ) {
    4545                        for ( typename ListType::const_iterator j = current->begin(); j != current->end(); ++j ) {
     
    5252                } // for
    5353        }
    54 
     54 
    5555        // in AdjustExprType.cc
    5656        /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
     
    144144        }
    145145
    146         /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value.
    147         Type * extractResultType( FunctionType * functionType );
    148 
    149146        // in CommonType.cc
    150147        Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
     
    155152        // in Occurs.cc
    156153        bool occurs( Type *type, std::string varName, const TypeEnvironment &env );
    157 
    158         // flatten tuple type into list of types
    159         template< typename OutputIterator >
    160         void flatten( Type * type, OutputIterator out ) {
    161                 if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) {
    162                         for ( Type * t : tupleType->get_types() ) {
    163                                 flatten( t, out );
    164                         }
    165                 } else {
    166                         *out++ = type;
    167                 }
    168         }
    169154} // namespace ResolvExpr
    170155
  • src/SymTab/Autogen.cc

    raa8f9df rfd782b2  
    116116                // This happens before function pointer type conversion, so need to do it manually here
    117117                VariableExpr * assignVarExpr = new VariableExpr( assignDecl );
    118                 Type * assignVarExprType = assignVarExpr->get_result();
     118                Type *& assignVarExprType = assignVarExpr->get_results().front();
    119119                assignVarExprType = new PointerType( Type::Qualifiers(), assignVarExprType );
    120                 assignVarExpr->set_result( assignVarExprType );
    121120                ApplicationExpr * assignExpr = new ApplicationExpr( assignVarExpr );
    122121                assignExpr->get_args().push_back( new VariableExpr( dstParam ) );
  • src/SymTab/Indexer.cc

    raa8f9df rfd782b2  
    4040
    4141namespace SymTab {
    42         template< typename TreeType, typename VisitorType >
    43         inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) {
     42        template< typename Container, typename VisitorType >
     43        inline void acceptAllNewScope( Container &container, VisitorType &visitor ) {
    4444                visitor.enterScope();
    45                 maybeAccept( tree, visitor );
     45                acceptAll( container, visitor );
    4646                visitor.leaveScope();
    4747        }
     
    337337
    338338        void Indexer::visit( ApplicationExpr *applicationExpr ) {
    339                 acceptNewScope( applicationExpr->get_result(), *this );
     339                acceptAllNewScope( applicationExpr->get_results(), *this );
    340340                maybeAccept( applicationExpr->get_function(), *this );
    341341                acceptAll( applicationExpr->get_args(), *this );
     
    343343
    344344        void Indexer::visit( UntypedExpr *untypedExpr ) {
    345                 acceptNewScope( untypedExpr->get_result(), *this );
     345                acceptAllNewScope( untypedExpr->get_results(), *this );
    346346                acceptAll( untypedExpr->get_args(), *this );
    347347        }
    348348
    349349        void Indexer::visit( NameExpr *nameExpr ) {
    350                 acceptNewScope( nameExpr->get_result(), *this );
     350                acceptAllNewScope( nameExpr->get_results(), *this );
    351351        }
    352352
    353353        void Indexer::visit( AddressExpr *addressExpr ) {
    354                 acceptNewScope( addressExpr->get_result(), *this );
     354                acceptAllNewScope( addressExpr->get_results(), *this );
    355355                maybeAccept( addressExpr->get_arg(), *this );
    356356        }
    357357
    358358        void Indexer::visit( LabelAddressExpr *labAddressExpr ) {
    359                 acceptNewScope( labAddressExpr->get_result(), *this );
     359                acceptAllNewScope( labAddressExpr->get_results(), *this );
    360360                maybeAccept( labAddressExpr->get_arg(), *this );
    361361        }
    362362
    363363        void Indexer::visit( CastExpr *castExpr ) {
    364                 acceptNewScope( castExpr->get_result(), *this );
     364                acceptAllNewScope( castExpr->get_results(), *this );
    365365                maybeAccept( castExpr->get_arg(), *this );
    366366        }
    367367
    368368        void Indexer::visit( UntypedMemberExpr *memberExpr ) {
    369                 acceptNewScope( memberExpr->get_result(), *this );
     369                acceptAllNewScope( memberExpr->get_results(), *this );
    370370                maybeAccept( memberExpr->get_aggregate(), *this );
    371371        }
    372372
    373373        void Indexer::visit( MemberExpr *memberExpr ) {
    374                 acceptNewScope( memberExpr->get_result(), *this );
     374                acceptAllNewScope( memberExpr->get_results(), *this );
    375375                maybeAccept( memberExpr->get_aggregate(), *this );
    376376        }
    377377
    378378        void Indexer::visit( VariableExpr *variableExpr ) {
    379                 acceptNewScope( variableExpr->get_result(), *this );
     379                acceptAllNewScope( variableExpr->get_results(), *this );
    380380        }
    381381
    382382        void Indexer::visit( ConstantExpr *constantExpr ) {
    383                 acceptNewScope( constantExpr->get_result(), *this );
     383                acceptAllNewScope( constantExpr->get_results(), *this );
    384384                maybeAccept( constantExpr->get_constant(), *this );
    385385        }
    386386
    387387        void Indexer::visit( SizeofExpr *sizeofExpr ) {
    388                 acceptNewScope( sizeofExpr->get_result(), *this );
     388                acceptAllNewScope( sizeofExpr->get_results(), *this );
    389389                if ( sizeofExpr->get_isType() ) {
    390390                        maybeAccept( sizeofExpr->get_type(), *this );
     
    395395
    396396        void Indexer::visit( AlignofExpr *alignofExpr ) {
    397                 acceptNewScope( alignofExpr->get_result(), *this );
     397                acceptAllNewScope( alignofExpr->get_results(), *this );
    398398                if ( alignofExpr->get_isType() ) {
    399399                        maybeAccept( alignofExpr->get_type(), *this );
     
    404404
    405405        void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) {
    406                 acceptNewScope( offsetofExpr->get_result(), *this );
     406                acceptAllNewScope( offsetofExpr->get_results(), *this );
    407407                maybeAccept( offsetofExpr->get_type(), *this );
    408408        }
    409409
    410410        void Indexer::visit( OffsetofExpr *offsetofExpr ) {
    411                 acceptNewScope( offsetofExpr->get_result(), *this );
     411                acceptAllNewScope( offsetofExpr->get_results(), *this );
    412412                maybeAccept( offsetofExpr->get_type(), *this );
    413413                maybeAccept( offsetofExpr->get_member(), *this );
     
    415415
    416416        void Indexer::visit( OffsetPackExpr *offsetPackExpr ) {
    417                 acceptNewScope( offsetPackExpr->get_result(), *this );
     417                acceptAllNewScope( offsetPackExpr->get_results(), *this );
    418418                maybeAccept( offsetPackExpr->get_type(), *this );
    419419        }
    420420
    421421        void Indexer::visit( AttrExpr *attrExpr ) {
    422                 acceptNewScope( attrExpr->get_result(), *this );
     422                acceptAllNewScope( attrExpr->get_results(), *this );
    423423                if ( attrExpr->get_isType() ) {
    424424                        maybeAccept( attrExpr->get_type(), *this );
     
    429429
    430430        void Indexer::visit( LogicalExpr *logicalExpr ) {
    431                 acceptNewScope( logicalExpr->get_result(), *this );
     431                acceptAllNewScope( logicalExpr->get_results(), *this );
    432432                maybeAccept( logicalExpr->get_arg1(), *this );
    433433                maybeAccept( logicalExpr->get_arg2(), *this );
     
    435435
    436436        void Indexer::visit( ConditionalExpr *conditionalExpr ) {
    437                 acceptNewScope( conditionalExpr->get_result(), *this );
     437                acceptAllNewScope( conditionalExpr->get_results(), *this );
    438438                maybeAccept( conditionalExpr->get_arg1(), *this );
    439439                maybeAccept( conditionalExpr->get_arg2(), *this );
     
    442442
    443443        void Indexer::visit( CommaExpr *commaExpr ) {
    444                 acceptNewScope( commaExpr->get_result(), *this );
     444                acceptAllNewScope( commaExpr->get_results(), *this );
    445445                maybeAccept( commaExpr->get_arg1(), *this );
    446446                maybeAccept( commaExpr->get_arg2(), *this );
     
    448448
    449449        void Indexer::visit( TupleExpr *tupleExpr ) {
    450                 acceptNewScope( tupleExpr->get_result(), *this );
     450                acceptAllNewScope( tupleExpr->get_results(), *this );
    451451                acceptAll( tupleExpr->get_exprs(), *this );
    452452        }
    453453
    454454        void Indexer::visit( TupleAssignExpr *tupleExpr ) {
    455                 acceptNewScope( tupleExpr->get_result(), *this );
     455                acceptAllNewScope( tupleExpr->get_results(), *this );
    456456                enterScope();
    457457                acceptAll( tupleExpr->get_tempDecls(), *this );
     
    461461
    462462        void Indexer::visit( TypeExpr *typeExpr ) {
    463                 acceptNewScope( typeExpr->get_result(), *this );
     463                acceptAllNewScope( typeExpr->get_results(), *this );
    464464                maybeAccept( typeExpr->get_type(), *this );
    465465        }
     
    472472
    473473        void Indexer::visit( UntypedValofExpr *valofExpr ) {
    474                 acceptNewScope( valofExpr->get_result(), *this );
     474                acceptAllNewScope( valofExpr->get_results(), *this );
    475475                maybeAccept( valofExpr->get_body(), *this );
    476476        }
  • src/SynTree/AddressExpr.cc

    raa8f9df rfd782b2  
    1919
    2020AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) {
    21         if ( arg->has_result() ) {
    22                 set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) );
    23         }
     21        for ( std::list< Type* >::const_iterator i = arg->get_results().begin(); i != arg->get_results().end(); ++i ) {
     22                get_results().push_back( new PointerType( Type::Qualifiers(), (*i)->clone() ) );
     23        } // for
    2424}
    2525
     
    3535        if ( arg ) {
    3636                os << std::string( indent+2, ' ' );
    37                 arg->print( os, indent+2 );
     37    arg->print( os, indent+2 );
    3838        } // if
    3939}
  • src/SynTree/ApplicationExpr.cc

    raa8f9df rfd782b2  
    2121#include "TypeSubstitution.h"
    2222#include "Common/utility.h"
    23 #include "ResolvExpr/typeops.h"
     23
    2424
    2525ParamEntry::ParamEntry( const ParamEntry &other ) :
     
    4343
    4444ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
    45         PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() );
    46         FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     45        PointerType *pointer = dynamic_cast< PointerType* >( funcExpr->get_results().front() );
     46        assert( pointer );
     47        FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
     48        assert( function );
    4749
    48         set_result( ResolvExpr::extractResultType( function ) );
    49 
    50         assert( has_result() );
     50        for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
     51                get_results().push_back( (*i)->get_type()->clone() );
     52        } // for
    5153}
    5254
  • src/SynTree/CommaExpr.cc

    raa8f9df rfd782b2  
    2323        // to false on all result types. Actually doing this causes some strange things
    2424        // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.
    25         set_result( maybeClone( arg2->get_result() ) );
    26         // get_type->set_isLvalue( false );
     25        cloneAll( arg2->get_results(), get_results() );
     26        // for ( Type *& type : get_results() ) {
     27        //      type->set_isLvalue( false );
     28        // }
    2729}
    2830
  • src/SynTree/Expression.cc

    raa8f9df rfd782b2  
    3131
    3232
    33 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
    34 
    35 Expression::Expression( const Expression &other ) : result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
     33Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
     34
     35Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
     36        cloneAll( other.results, results );
    3637}
    3738
     
    3940        delete env;
    4041        delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
    41         delete result;
     42        deleteAll( results );
     43}
     44
     45void Expression::add_result( Type *t ) {
     46        if ( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) {
     47                std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) );
     48        } else {
     49                results.push_back(t);
     50        } // if
    4251}
    4352
     
    5968
    6069ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
    61         set_result( constant.get_type()->clone() );
     70        add_result( constant.get_type()->clone() );
    6271}
    6372
     
    7685        assert( var );
    7786        assert( var->get_type() );
    78         Type * type = var->get_type()->clone();
    79         type->set_isLvalue( true );
    80         set_result( type );
     87        add_result( var->get_type()->clone() );
     88        for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
     89                (*i)->set_isLvalue( true );
     90        } // for
    8191}
    8292
     
    100110SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    101111                Expression( _aname ), expr(expr_), type(0), isType(false) {
    102         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     112        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    103113}
    104114
    105115SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    106116                Expression( _aname ), expr(0), type(type_), isType(true) {
    107         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     117        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    108118}
    109119
     
    131141AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    132142                Expression( _aname ), expr(expr_), type(0), isType(false) {
    133         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     143        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    134144}
    135145
    136146AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    137147                Expression( _aname ), expr(0), type(type_), isType(true) {
    138         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     148        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    139149}
    140150
     
    162172UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
    163173                Expression( _aname ), type(type_), member(member_) {
    164         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     174        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    165175}
    166176
     
    187197OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
    188198                Expression( _aname ), type(type_), member(member_) {
    189         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     199        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    190200}
    191201
     
    219229
    220230OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
    221         set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     231        add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    222232}
    223233
     
    274284
    275285CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    276         set_result(toType);
     286        add_result(toType);
    277287}
    278288
    279289CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    280         set_result( new VoidType( Type::Qualifiers() ) );
    281290}
    282291
     
    294303        arg->print(os, indent+2);
    295304        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
    296         os << std::string( indent+2, ' ' );
    297         if ( result->isVoid() ) {
    298                 os << "nothing";
     305        if ( results.empty() ) {
     306                os << std::string( indent+2, ' ' ) << "nothing" << std::endl;
    299307        } else {
    300                 result->print( os, indent+2 );
     308                printAll(results, os, indent+2);
    301309        } // if
    302         os << std::endl;
    303310        Expression::print( os, indent );
    304311}
     
    334341MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
    335342                Expression( _aname ), member(_member), aggregate(_aggregate) {
    336         set_result( member->get_type()->clone() );
    337         get_result()->set_isLvalue( true );
     343        add_result( member->get_type()->clone() );
     344        for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
     345                (*i)->set_isLvalue( true );
     346        } // for
    338347}
    339348
     
    410419LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
    411420                Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    412         set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
     421        add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    413422}
    414423
     
    468477ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    469478        assert( callExpr );
    470         assert( callExpr->has_result() );
    471         set_result( callExpr->get_result()->clone() );
     479        cloneAll( callExpr->get_results(), results );
    472480}
    473481
     
    502510        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
    503511        assert( arg );
    504         set_result( maybeClone( arg->get_result() ) );
     512        cloneAll( arg->get_results(), results );
    505513}
    506514
     
    522530
    523531CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
    524         set_result( type->clone() );
     532        add_result( type->clone() );
    525533}
    526534
     
    562570        if ( ! body.empty() ) {
    563571                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
    564                         set_result( maybeClone( exprStmt->get_expr()->get_result() ) );
     572                        cloneAll( exprStmt->get_expr()->get_results(), get_results() );
    565573                }
    566574        }
  • src/SynTree/Expression.h

    raa8f9df rfd782b2  
    3232        virtual ~Expression();
    3333
    34         Type *& get_result() { return result; }
    35         void set_result( Type *newValue ) { result = newValue; }
    36         bool has_result() const { return result != nullptr; }
     34        std::list<Type *>& get_results() { return results; }
     35        void add_result( Type *t );
    3736
    3837        TypeSubstitution *get_env() const { return env; }
     
    4847        virtual void print( std::ostream &os, int indent = 0 ) const;
    4948  protected:
    50         Type * result;
     49        std::list<Type *> results;
    5150        TypeSubstitution *env;
    5251        Expression* argName; // if expression is used as an argument, it can be "designated" by this name
  • src/SynTree/Mutator.cc

    raa8f9df rfd782b2  
    178178
    179179Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
    180         applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
     180        mutateAll( applicationExpr->get_results(), *this );
    181181        applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
    182182        mutateAll( applicationExpr->get_args(), *this );
     
    185185
    186186Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
    187         untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
     187        mutateAll( untypedExpr->get_results(), *this );
    188188        mutateAll( untypedExpr->get_args(), *this );
    189189        return untypedExpr;
     
    191191
    192192Expression *Mutator::mutate( NameExpr *nameExpr ) {
    193         nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
     193        mutateAll( nameExpr->get_results(), *this );
    194194        return nameExpr;
    195195}
    196196
    197197Expression *Mutator::mutate( AddressExpr *addressExpr ) {
    198         addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
     198        mutateAll( addressExpr->get_results(), *this );
    199199        addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
    200200        return addressExpr;
     
    202202
    203203Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
    204         labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
     204        mutateAll( labelAddressExpr->get_results(), *this );
    205205        labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
    206206        return labelAddressExpr;
     
    208208
    209209Expression *Mutator::mutate( CastExpr *castExpr ) {
    210         castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
     210        mutateAll( castExpr->get_results(), *this );
    211211        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    212212        return castExpr;
     
    214214
    215215Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    216         memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
     216        mutateAll( memberExpr->get_results(), *this );
    217217        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    218218        memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
     
    221221
    222222Expression *Mutator::mutate( MemberExpr *memberExpr ) {
    223         memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
     223        mutateAll( memberExpr->get_results(), *this );
    224224        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    225225        return memberExpr;
     
    227227
    228228Expression *Mutator::mutate( VariableExpr *variableExpr ) {
    229         variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
     229        mutateAll( variableExpr->get_results(), *this );
    230230        return variableExpr;
    231231}
    232232
    233233Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
    234         constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
     234        mutateAll( constantExpr->get_results(), *this );
    235235//  maybeMutate( constantExpr->get_constant(), *this )
    236236        return constantExpr;
     
    238238
    239239Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
    240         sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
     240        mutateAll( sizeofExpr->get_results(), *this );
    241241        if ( sizeofExpr->get_isType() ) {
    242242                sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
     
    248248
    249249Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
    250         alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
     250        mutateAll( alignofExpr->get_results(), *this );
    251251        if ( alignofExpr->get_isType() ) {
    252252                alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
     
    258258
    259259Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
    260         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
     260        mutateAll( offsetofExpr->get_results(), *this );
    261261        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    262262        return offsetofExpr;
     
    264264
    265265Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
    266         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
     266        mutateAll( offsetofExpr->get_results(), *this );
    267267        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    268268        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
     
    271271
    272272Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
    273         offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
     273        mutateAll( offsetPackExpr->get_results(), *this );
    274274        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
    275275        return offsetPackExpr;
     
    277277
    278278Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    279         attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
     279        mutateAll( attrExpr->get_results(), *this );
    280280        if ( attrExpr->get_isType() ) {
    281281                attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
     
    287287
    288288Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
    289         logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
     289        mutateAll( logicalExpr->get_results(), *this );
    290290        logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
    291291        logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
     
    294294
    295295Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
    296         conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
     296        mutateAll( conditionalExpr->get_results(), *this );
    297297        conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
    298298        conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
     
    302302
    303303Expression *Mutator::mutate( CommaExpr *commaExpr ) {
    304         commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
     304        mutateAll( commaExpr->get_results(), *this );
    305305        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
    306306        commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
     
    309309
    310310Expression *Mutator::mutate( TypeExpr *typeExpr ) {
    311         typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
     311        mutateAll( typeExpr->get_results(), *this );
    312312        typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
    313313        return typeExpr;
     
    329329
    330330Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
    331         ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
     331        mutateAll( ctorExpr->get_results(), *this );
    332332        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
    333333        return ctorExpr;
     
    335335
    336336Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
    337         compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
     337        mutateAll( compLitExpr->get_results(), *this );
    338338        compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
    339339        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
     
    342342
    343343Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    344         valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
     344        mutateAll( valofExpr->get_results(), *this );
    345345        return valofExpr;
    346346}
     
    353353
    354354Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
    355         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     355        mutateAll( tupleExpr->get_results(), *this );
    356356        mutateAll( tupleExpr->get_exprs(), *this );
    357357        return tupleExpr;
     
    359359
    360360Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
    361         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     361        mutateAll( tupleExpr->get_results(), *this );
    362362        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
    363363        return tupleExpr;
     
    365365
    366366Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {
    367         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     367        mutateAll( tupleExpr->get_results(), *this );
    368368        tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );
    369369        tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) );
     
    372372
    373373Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
    374         assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
     374        mutateAll( assignExpr->get_results(), *this );
    375375        mutateAll( assignExpr->get_tempDecls(), *this );
    376376        mutateAll( assignExpr->get_assigns(), *this );
     
    379379
    380380Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
    381         stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
     381        mutateAll( stmtExpr->get_results(), *this );
    382382        stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
    383383        return stmtExpr;
  • src/SynTree/TupleExpr.cc

    raa8f9df rfd782b2  
    3131
    3232void TupleExpr::print( std::ostream &os, int indent ) const {
    33         os << "Tuple:" << std::endl;
     33        os << std::string( indent, ' ' ) << "Tuple:" << std::endl;
    3434        printAll( exprs, os, indent+2 );
    3535        Expression::print( os, indent );
     
    3737
    3838TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) {
    39         TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() );
    40         assert( type->size() >= index );
    41         set_result( *std::next( type->get_types().begin(), index ) );
     39        // TupleType * type = safe_dynamic_cast< TypeType * >( tuple->get_ )
     40        assert( tuple->get_results().size() >= index );
     41        add_result( *std::next( tuple->get_results().begin(), index ) );
    4242}
    4343
     
    5050
    5151void TupleIndexExpr::print( std::ostream &os, int indent ) const {
    52         os << "Tuple Index Expression, with tuple:" << std::endl;
     52        os << std::string( indent, ' ' ) << "Tuple Index Expression, with tuple:" << std::endl;
    5353        tuple->print( os, indent+2 );
    5454        os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl;
     
    5757
    5858MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
    59         set_result( maybeClone( member->get_result() ) ); // xxx - ???
     59        cloneAll( member->get_results(), get_results() ); // xxx - ???
    6060}
    6161
     
    6969
    7070void MemberTupleExpr::print( std::ostream &os, int indent ) const {
    71         os << "Member Tuple Expression, with aggregate:" << std::endl;
     71        os << std::string( indent, ' ' ) << "Member Tuple Expression, with aggregate:" << std::endl;
    7272        aggregate->print( os, indent+2 );
    7373        os << std::string( indent+2, ' ' ) << "with member: " << std::endl;
     
    7878
    7979TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) {
    80         TupleType * type = new TupleType( Type::Qualifiers() );
    8180        for ( Expression * expr : assigns ) {
    82                 assert( expr->has_result() );
    83                 type->get_types().push_back( expr->get_result()->clone() );
     81                cloneAll( expr->get_results(), get_results() );
    8482        }
    85         set_result( type );
    8683}
    8784
  • src/SynTree/Type.h

    raa8f9df rfd782b2  
    2727                Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
    2828
    29                 Qualifiers &operator&=( const Qualifiers &other );
    3029                Qualifiers &operator+=( const Qualifiers &other );
    3130                Qualifiers &operator-=( const Qualifiers &other );
     
    6665        std::list<TypeDecl*>& get_forall() { return forall; }
    6766
    68         /// How many elemental types are represented by this type
    69         virtual unsigned size() const { return 1; };
    70         virtual bool isVoid() const { return size() == 0; }
    71 
    7267        virtual Type *clone() const = 0;
    7368        virtual void accept( Visitor &v ) = 0;
     
    8277  public:
    8378        VoidType( const Type::Qualifiers &tq );
    84 
    85         virtual unsigned size() const { return 0; };
    8679
    8780        virtual VoidType *clone() const { return new VoidType( *this ); }
     
    364357
    365358        std::list<Type*>& get_types() { return types; }
    366         virtual unsigned size() const { return types.size(); };
    367359
    368360        iterator begin() { return types.begin(); }
     
    433425};
    434426
    435 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) {
    436         isConst &= other.isConst;
    437         isVolatile &= other.isVolatile;
    438         isRestrict &= other.isRestrict;
    439         isLvalue &= other.isLvalue;
    440         isAtomic &= other.isAtomic;
    441         return *this;
    442 }
    443 
    444427inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    445428        isConst |= other.isConst;
  • src/SynTree/Visitor.cc

    raa8f9df rfd782b2  
    150150
    151151void Visitor::visit( ApplicationExpr *applicationExpr ) {
    152         maybeAccept( applicationExpr->get_result(), *this );
     152        acceptAll( applicationExpr->get_results(), *this );
    153153        maybeAccept( applicationExpr->get_function(), *this );
    154154        acceptAll( applicationExpr->get_args(), *this );
     
    156156
    157157void Visitor::visit( UntypedExpr *untypedExpr ) {
    158         maybeAccept( untypedExpr->get_result(), *this );
     158        acceptAll( untypedExpr->get_results(), *this );
    159159        acceptAll( untypedExpr->get_args(), *this );
    160160}
    161161
    162162void Visitor::visit( NameExpr *nameExpr ) {
    163         maybeAccept( nameExpr->get_result(), *this );
     163        acceptAll( nameExpr->get_results(), *this );
    164164}
    165165
    166166void Visitor::visit( AddressExpr *addressExpr ) {
    167         maybeAccept( addressExpr->get_result(), *this );
     167        acceptAll( addressExpr->get_results(), *this );
    168168        maybeAccept( addressExpr->get_arg(), *this );
    169169}
    170170
    171171void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
    172         maybeAccept( labAddressExpr->get_result(), *this );
     172        acceptAll( labAddressExpr->get_results(), *this );
    173173        maybeAccept( labAddressExpr->get_arg(), *this );
    174174}
    175175
    176176void Visitor::visit( CastExpr *castExpr ) {
    177         maybeAccept( castExpr->get_result(), *this );
     177        acceptAll( castExpr->get_results(), *this );
    178178        maybeAccept( castExpr->get_arg(), *this );
    179179}
    180180
    181181void Visitor::visit( UntypedMemberExpr *memberExpr ) {
    182         maybeAccept( memberExpr->get_result(), *this );
     182        acceptAll( memberExpr->get_results(), *this );
    183183        maybeAccept( memberExpr->get_aggregate(), *this );
    184184        maybeAccept( memberExpr->get_member(), *this );
     
    186186
    187187void Visitor::visit( MemberExpr *memberExpr ) {
    188         maybeAccept( memberExpr->get_result(), *this );
     188        acceptAll( memberExpr->get_results(), *this );
    189189        maybeAccept( memberExpr->get_aggregate(), *this );
    190190}
    191191
    192192void Visitor::visit( VariableExpr *variableExpr ) {
    193         maybeAccept( variableExpr->get_result(), *this );
     193        acceptAll( variableExpr->get_results(), *this );
    194194}
    195195
    196196void Visitor::visit( ConstantExpr *constantExpr ) {
    197         maybeAccept( constantExpr->get_result(), *this );
     197        acceptAll( constantExpr->get_results(), *this );
    198198        maybeAccept( constantExpr->get_constant(), *this );
    199199}
    200200
    201201void Visitor::visit( SizeofExpr *sizeofExpr ) {
    202         maybeAccept( sizeofExpr->get_result(), *this );
     202        acceptAll( sizeofExpr->get_results(), *this );
    203203        if ( sizeofExpr->get_isType() ) {
    204204                maybeAccept( sizeofExpr->get_type(), *this );
     
    209209
    210210void Visitor::visit( AlignofExpr *alignofExpr ) {
    211         maybeAccept( alignofExpr->get_result(), *this );
     211        acceptAll( alignofExpr->get_results(), *this );
    212212        if ( alignofExpr->get_isType() ) {
    213213                maybeAccept( alignofExpr->get_type(), *this );
     
    218218
    219219void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
    220         maybeAccept( offsetofExpr->get_result(), *this );
     220        acceptAll( offsetofExpr->get_results(), *this );
    221221        maybeAccept( offsetofExpr->get_type(), *this );
    222222}
    223223
    224224void Visitor::visit( OffsetofExpr *offsetofExpr ) {
    225         maybeAccept( offsetofExpr->get_result(), *this );
     225        acceptAll( offsetofExpr->get_results(), *this );
    226226        maybeAccept( offsetofExpr->get_type(), *this );
    227227        maybeAccept( offsetofExpr->get_member(), *this );
     
    229229
    230230void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
    231         maybeAccept( offsetPackExpr->get_result(), *this );
     231        acceptAll( offsetPackExpr->get_results(), *this );
    232232        maybeAccept( offsetPackExpr->get_type(), *this );
    233233}
    234234
    235235void Visitor::visit( AttrExpr *attrExpr ) {
    236         maybeAccept( attrExpr->get_result(), *this );
     236        acceptAll( attrExpr->get_results(), *this );
    237237        if ( attrExpr->get_isType() ) {
    238238                maybeAccept( attrExpr->get_type(), *this );
     
    243243
    244244void Visitor::visit( LogicalExpr *logicalExpr ) {
    245         maybeAccept( logicalExpr->get_result(), *this );
     245        acceptAll( logicalExpr->get_results(), *this );
    246246        maybeAccept( logicalExpr->get_arg1(), *this );
    247247        maybeAccept( logicalExpr->get_arg2(), *this );
     
    249249
    250250void Visitor::visit( ConditionalExpr *conditionalExpr ) {
    251         maybeAccept( conditionalExpr->get_result(), *this );
     251        acceptAll( conditionalExpr->get_results(), *this );
    252252        maybeAccept( conditionalExpr->get_arg1(), *this );
    253253        maybeAccept( conditionalExpr->get_arg2(), *this );
     
    256256
    257257void Visitor::visit( CommaExpr *commaExpr ) {
    258         maybeAccept( commaExpr->get_result(), *this );
     258        acceptAll( commaExpr->get_results(), *this );
    259259        maybeAccept( commaExpr->get_arg1(), *this );
    260260        maybeAccept( commaExpr->get_arg2(), *this );
     
    262262
    263263void Visitor::visit( TypeExpr *typeExpr ) {
    264         maybeAccept( typeExpr->get_result(), *this );
     264        acceptAll( typeExpr->get_results(), *this );
    265265        maybeAccept( typeExpr->get_type(), *this );
    266266}
     
    279279
    280280void Visitor::visit( ConstructorExpr * ctorExpr ) {
    281         maybeAccept( ctorExpr->get_result(), *this );
     281        acceptAll( ctorExpr->get_results(), *this );
    282282        maybeAccept( ctorExpr->get_callExpr(), *this );
    283283}
    284284
    285285void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
    286         maybeAccept( compLitExpr->get_result(), *this );
     286        acceptAll( compLitExpr->get_results(), *this );
    287287        maybeAccept( compLitExpr->get_type(), *this );
    288288        maybeAccept( compLitExpr->get_initializer(), *this );
     
    290290
    291291void Visitor::visit( UntypedValofExpr *valofExpr ) {
    292         maybeAccept( valofExpr->get_result(), *this );
     292        acceptAll( valofExpr->get_results(), *this );
    293293        maybeAccept( valofExpr->get_body(), *this );
    294294}
     
    300300
    301301void Visitor::visit( TupleExpr *tupleExpr ) {
    302         maybeAccept( tupleExpr->get_result(), *this );
     302        acceptAll( tupleExpr->get_results(), *this );
    303303        acceptAll( tupleExpr->get_exprs(), *this );
    304304}
    305305
    306306void Visitor::visit( TupleIndexExpr *tupleExpr ) {
    307         maybeAccept( tupleExpr->get_result(), *this );
     307        acceptAll( tupleExpr->get_results(), *this );
    308308        maybeAccept( tupleExpr->get_tuple(), *this );
    309309}
    310310
    311311void Visitor::visit( MemberTupleExpr *tupleExpr ) {
    312         maybeAccept( tupleExpr->get_result(), *this );
     312        acceptAll( tupleExpr->get_results(), *this );
    313313        maybeAccept( tupleExpr->get_member(), *this );
    314314        maybeAccept( tupleExpr->get_aggregate(), *this );
     
    316316
    317317void Visitor::visit( TupleAssignExpr *assignExpr ) {
    318         maybeAccept( assignExpr->get_result(), *this );
     318        acceptAll( assignExpr->get_results(), *this );
    319319        acceptAll( assignExpr->get_tempDecls(), *this );
    320320        acceptAll( assignExpr->get_assigns(), *this );
     
    322322
    323323void Visitor::visit( StmtExpr *stmtExpr ) {
    324         maybeAccept( stmtExpr->get_result(), *this );
     324        acceptAll( stmtExpr->get_results(), *this );
    325325        maybeAccept( stmtExpr->get_statements(), *this );
    326326}
  • src/Tuples/TupleAssignment.cc

    raa8f9df rfd782b2  
    8888        bool isTuple( Expression *expr ) {
    8989                if ( ! expr ) return false;
    90                 assert( expr->has_result() );
     90
    9191                // xxx - used to include cast to varExpr and call to isTupleVar, but this doesn't seem like it should be necessary
    92                 return dynamic_cast<TupleExpr *>(expr) || expr->get_result()->size() > 1;
     92                return dynamic_cast<TupleExpr *>(expr) || expr->get_results().size() > 1;
    9393        }
    9494
     
    102102
    103103        bool isTupleExpr( Expression *expr ) {
    104                 assert( expr->has_result() );
    105                 return expr->get_result()->size() > 1;
     104                return expr->get_results().size() > 1;
    106105        }
    107106
     
    192191
    193192        ObjectDecl * newObject( UniqueName & namer, Expression * expr ) {
    194                 assert( expr->has_result() && ! expr->get_result()->isVoid() );
    195                 return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );
     193                Type * type;
     194                assert( expr->get_results().size() >= 1 );
     195                if ( expr->get_results().size() > 1 ) {
     196                        TupleType * tt = new TupleType( Type::Qualifiers() );
     197                        cloneAll( expr->get_results(), tt->get_types() );
     198                        type = tt;
     199                } else {
     200                        type = expr->get_results().front()->clone();
     201                }
     202                return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, type, new SingleInit( expr->clone() ) );
    196203        }
    197204
  • src/Tuples/TupleExpansion.cc

    raa8f9df rfd782b2  
    8585                        addDeclaration( decl );
    8686                }
    87                 Type::Qualifiers qualifiers = newType->get_qualifiers();
    8887                delete newType;
    89                 return new StructInstType( qualifiers, typeMap[mangleName] );
     88                return new StructInstType( newType->get_qualifiers(), typeMap[mangleName] );
    9089        }
    9190
Note: See TracChangeset for help on using the changeset viewer.