Changeset aadc9a4 for src/GenPoly/GenPoly.cc
- Timestamp:
- Jan 12, 2016, 6:12:10 PM (9 years ago)
- 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, string, with_gc
- Children:
- 4d7e8f5
- Parents:
- ebe9b3a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/GenPoly.cc
rebe9b3a raadc9a4 36 36 } 37 37 38 bool isPolyRet( FunctionType *function, std::string &name, const TyVarMap &otherTyVars ) { 39 bool doTransform = false; 38 ReferenceToType *isPolyRet( FunctionType *function ) { 40 39 if ( ! function->get_returnVals().empty() ) { 41 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( function->get_returnVals().front()->get_type() ) ) { 42 43 // figure out if the return type is specified by a type parameter 44 for ( std::list< TypeDecl *>::const_iterator tyVar = function->get_forall().begin(); tyVar != function->get_forall().end(); ++tyVar ) { 45 if ( (*tyVar)->get_name() == typeInst->get_name() ) { 46 doTransform = true; 47 name = typeInst->get_name(); 48 break; 49 } // if 50 } // for 51 if ( ! doTransform && otherTyVars.find( typeInst->get_name() ) != otherTyVars.end() ) { 52 doTransform = true; 53 } // if 54 } // if 40 TyVarMap forallTypes; 41 makeTyVarMap( function, forallTypes ); 42 return (ReferenceToType*)isPolyType( function->get_returnVals().front()->get_type(), forallTypes ); 55 43 } // if 56 return doTransform; 57 } 58 59 bool isPolyRet( FunctionType *function, std::string &name ) { 60 TyVarMap dummyTyVars; 61 return isPolyRet( function, name, dummyTyVars ); 62 } 63 64 bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars ) { 65 std::string dummyString; 66 return isPolyRet( function, dummyString, otherTyVars ); 44 return 0; 67 45 } 68 46 … … 158 136 } 159 137 138 void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) { 139 for ( std::list< TypeDecl* >::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) { 140 assert( *tyVar ); 141 tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind(); 142 } 143 if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) { 144 makeTyVarMap( pointer->get_base(), tyVarMap ); 145 } 146 } 147 160 148 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) { 161 149 for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
Note: See TracChangeset
for help on using the changeset viewer.