Changeset 540de412


Ignore:
Timestamp:
May 2, 2016, 3:09:08 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
fbfde843
Parents:
d8ba086
Message:

'merge' type substitutions from resolved copy constructors, add case to getBaseVar for CommaExpr?

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rd8ba086 r540de412  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 29 12:16:11 2016
     12// Last Modified On : Mon May 02 14:49:01 2016
    1313// Update Count     : 295
    1414//
     
    785785                                        } else {
    786786                                                /// xxx - should this be an assertion?
    787                                                 throw SemanticError( "unbound type variable in application ", appExpr );
     787                                                throw SemanticError( "unbound type variable: " + tyParm->first + " in application ", appExpr );
    788788                                        } // if
    789789                                } // if
  • src/GenPoly/GenPoly.cc

    rd8ba086 r540de412  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenPoly.cc -- 
     7// GenPoly.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 15 16:11:18 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon May 02 14:53:33 2016
    1313// Update Count     : 13
    1414//
     
    8181                return 0;
    8282        }
    83        
     83
    8484        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    8585                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
     
    112112                return 0;
    113113        }
    114        
     114
    115115        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    116116                if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
     
    146146                return isPolyType( type, env );
    147147        }
    148        
     148
    149149        Type * hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels, const TypeSubstitution *env ) {
    150150                int dummy;
     
    192192                                if ( ! fn || fn->get_name() != std::string("*?") ) return 0;
    193193                                expr = *untypedExpr->begin_args();
     194                        } else if ( CommaExpr *commaExpr = dynamic_cast< CommaExpr* >( expr ) ) {
     195                                // copy constructors insert comma exprs, look at second argument which contains the variable
     196                                expr = commaExpr->get_arg2();
     197                                continue;
    194198                        } else break;
    195199
     
    209213                }
    210214        }
    211        
     215
    212216        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) {
    213217                for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
  • src/GenPoly/PolyMutator.cc

    rd8ba086 r540de412  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // PolyMutator.cc -- 
     7// PolyMutator.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Aug 14 15:28:50 2015
     12// Last Modified On : Mon May 02 14:50:58 2016
    1313// Update Count     : 11
    1414//
     
    6363                                env = expr->get_env();
    6464                        }
     65                        // xxx - should env be cloned (or moved) onto the result of the mutate?
    6566                        return expr->acceptMutator( *this );
    6667                } else {
     
    144145                return untypedExpr;
    145146        }
    146  
    147  
     147
     148
    148149        Initializer *PolyMutator::mutate( SingleInit *singleInit ) {
    149150                singleInit->set_value( mutateExpression( singleInit->get_value() ) );
  • src/InitTweak/FixInit.cc

    rd8ba086 r540de412  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 29 12:25:40 2016
     12// Last Modified On : Mon May 02 14:57:45 2016
    1313// Update Count     : 30
    1414//
     
    6161                /// true if type does not need to be copy constructed to ensure correctness
    6262                bool skipCopyConstruct( Type * );
     63        private:
     64                TypeSubstitution * env;
    6365        };
    6466
     
    151153                // wrap each function call so that it is easy to identify nodes that have to be copy constructed
    152154                ImplicitCopyCtorExpr * expr = new ImplicitCopyCtorExpr( appExpr );
    153                 // save a copy of the type substitution onto the new node so that it is easy to find.
     155                // save the type substitution onto the new node so that it is easy to find.
     156                // Ensure it is not deleted with the ImplicitCopyCtorExpr by removing it before deletion.
    154157                // The substitution is needed to obtain the type of temporary variables so that copy constructor
    155158                // calls can be resolved. Normally this is what PolyMutator is for, but the pass that resolves
    156159                // copy constructor calls must be an Indexer. We could alternatively make a PolyIndexer which
    157                 // saves the environment, or compute the types of temporaries here, but it's more simpler to
     160                // saves the environment, or compute the types of temporaries here, but it's much simpler to
    158161                // save the environment here, and more cohesive to compute temporary variables and resolve copy
    159162                // constructor calls together.
    160163                assert( env );
    161                 expr->set_env( env->clone() );
     164                expr->set_env( env );
    162165                return expr;
    163166        }
     
    178181                PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; )
    179182                ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) );
     183                if ( resolved->get_env() ) {
     184                        env->add( *resolved->get_env() );
     185                }
    180186
    181187                assert( resolved );
     
    190196                PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
    191197                Visitor::visit( impCpCtorExpr );
     198                env = impCpCtorExpr->get_env(); // xxx - maybe we really should just have a PolyIndexer...
    192199
    193200                ApplicationExpr * appExpr = impCpCtorExpr->get_callExpr();
     
    246253                PRINT( std::cerr << "FixCopyCtors: " << impCpCtorExpr << std::endl; )
    247254
    248                 // assert( impCpCtorExpr->get_callExpr()->get_env() );
    249255                impCpCtorExpr = dynamic_cast< ImplicitCopyCtorExpr * >( Mutator::mutate( impCpCtorExpr ) );
    250256                assert( impCpCtorExpr );
     
    278284                returnDecls.clear();
    279285                impCpCtorExpr->set_callExpr( NULL );
     286                impCpCtorExpr->set_env( NULL );
    280287                delete impCpCtorExpr;
    281288
     
    311318                                retExpr = deref;
    312319                        }
     320                        // xxx - might need to set env on retExpr...
     321                        // retExpr->set_env( env->clone() );
    313322                        return retExpr;
    314323                } else {
  • src/SynTree/TypeSubstitution.h

    rd8ba086 r540de412  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 29 13:50:09 2016
     12// Last Modified On : Fri Apr 29 15:00:20 2016
    1313// Update Count     : 2
    1414//
     
    4848        void add( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin );
    4949
     50        /// this function is unused...
    5051        template< typename TypeInstListIterator >
    5152        void extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result );
Note: See TracChangeset for help on using the changeset viewer.