Ignore:
Timestamp:
Jun 30, 2016, 4:32:56 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, 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:
ea29e73
Parents:
1b5c81ed (diff), 84d4d6f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into gc_noraii

Conflicts:

Jenkinsfile
src/SymTab/Validate.cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/GenPoly.cc

    r1b5c81ed rf80e0218  
    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 : Wed May 25 13:39:21 2016
    1313// Update Count     : 13
    1414//
     
    6666        }
    6767
     68        Type* replaceTypeInst( Type* type, const TypeSubstitution* env ) {
     69                if ( ! env ) return type;
     70                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) {
     71                        Type *newType = env->lookup( typeInst->get_name() );
     72                        if ( newType ) return newType;
     73                }
     74                return type;
     75        }
     76
    6877        Type *isPolyType( Type *type, const TypeSubstitution *env ) {
     78                type = replaceTypeInst( type, env );
     79
    6980                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
    70                         if ( env ) {
    71                                 if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    72                                         return isPolyType( newType, env );
    73                                 } // if
    74                         } // if
    7581                        return type;
    7682                } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {
     
    8187                return 0;
    8288        }
    83        
     89
    8490        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
     91                type = replaceTypeInst( type, env );
     92
    8593                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
    86                         if ( env ) {
    87                                 if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    88                                         return isPolyType( newType, tyVars, env );
    89                                 } // if
    90                         } // if
    9194                        if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) {
    9295                                return type;
     
    101104
    102105        Type *isPolyPtr( Type *type, const TypeSubstitution *env ) {
     106                type = replaceTypeInst( type, env );
     107
    103108                if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
    104109                        return isPolyType( ptr->get_base(), env );
    105                 } else if ( env ) {
    106                         if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) {
    107                                 if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    108                                         return isPolyPtr( newType, env );
    109                                 } // if
    110                         } // if
    111                 } // if
    112                 return 0;
    113         }
    114        
     110                }
     111                return 0;
     112        }
     113
    115114        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
     115                type = replaceTypeInst( type, env );
     116
    116117                if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
    117118                        return isPolyType( ptr->get_base(), tyVars, env );
    118                 } else if ( env ) {
    119                         if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) {
    120                                 if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    121                                         return isPolyPtr( newType, tyVars, env );
    122                                 } // if
    123                         } // if
    124                 } // if
     119                }
    125120                return 0;
    126121        }
     
    132127
    133128                while ( true ) {
     129                        type = replaceTypeInst( type, env );
     130
    134131                        if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
    135132                                type = ptr->get_base();
    136133                                ++(*levels);
    137                         } else if ( env ) {
    138                                 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) {
    139                                         if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    140                                                 type = newType;
    141                                         } else break;
    142                                 } else break;
    143134                        } else break;
    144135                }
     
    146137                return isPolyType( type, env );
    147138        }
    148        
     139
    149140        Type * hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels, const TypeSubstitution *env ) {
    150141                int dummy;
     
    153144
    154145                while ( true ) {
     146                        type = replaceTypeInst( type, env );
     147
    155148                        if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
    156149                                type = ptr->get_base();
    157150                                ++(*levels);
    158                         } else if ( env ) {
    159                                 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) {
    160                                         if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    161                                                 type = newType;
    162                                         } else break;
    163                                 } else break;
    164151                        } else break;
    165152                }
     
    185172                        if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( expr ) ) {
    186173                                return varExpr;
     174                        } else if ( MemberExpr *memberExpr = dynamic_cast< MemberExpr* >( expr ) ) {
     175                                expr = memberExpr->get_aggregate();
    187176                        } else if ( AddressExpr *addressExpr = dynamic_cast< AddressExpr* >( expr ) ) {
    188177                                expr = addressExpr->get_arg();
     
    192181                                if ( ! fn || fn->get_name() != std::string("*?") ) return 0;
    193182                                expr = *untypedExpr->begin_args();
     183                        } else if ( CommaExpr *commaExpr = dynamic_cast< CommaExpr* >( expr ) ) {
     184                                // copy constructors insert comma exprs, look at second argument which contains the variable
     185                                expr = commaExpr->get_arg2();
     186                                continue;
    194187                        } else break;
    195188
     
    209202                }
    210203        }
    211        
     204
    212205        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) {
    213206                for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
Note: See TracChangeset for help on using the changeset viewer.