Changes in src/GenPoly/GenPoly.cc [3bb195cb:ca35c51]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/GenPoly.cc
r3bb195cb rca35c51 23 23 24 24 namespace GenPoly { 25 bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) { 26 if ( ! adaptee->get_returnVals().empty() && isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) { 27 return true; 28 } // if 29 for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) { 30 if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) { 31 return true; 32 } // if 33 } // for 34 return false; 35 } 36 37 ReferenceToType *isPolyRet( FunctionType *function ) { 38 if ( ! function->get_returnVals().empty() ) { 39 TyVarMap forallTypes( (TypeDecl::Kind)-1 ); 40 makeTyVarMap( function, forallTypes ); 41 return (ReferenceToType*)isPolyType( function->get_returnVals().front()->get_type(), forallTypes ); 42 } // if 43 return 0; 44 } 45 25 46 namespace { 26 47 /// Checks a parameter list for polymorphic parameters; will substitute according to env if present … … 43 64 return false; 44 65 } 45 46 /// Checks a parameter list for dynamic-layout parameters from tyVars; will substitute according to env if present47 bool hasDynParams( std::list< Expression* >& params, const TyVarMap &tyVars, const TypeSubstitution *env ) {48 for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) {49 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param );50 assert(paramType && "Aggregate parameters should be type expressions");51 if ( isDynType( paramType->get_type(), tyVars, env ) ) return true;52 }53 return false;54 }55 66 } 56 67 … … 90 101 } 91 102 return 0; 92 }93 94 Type *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {95 type = replaceTypeInst( type, env );96 97 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {98 auto var = tyVars.find( typeInst->get_name() );99 if ( var != tyVars.end() && var->second == TypeDecl::Any ) {100 return type;101 }102 } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {103 if ( hasDynParams( structType->get_parameters(), tyVars, env ) ) return type;104 } else if ( UnionInstType *unionType = dynamic_cast< UnionInstType* >( type ) ) {105 if ( hasDynParams( unionType->get_parameters(), tyVars, env ) ) return type;106 }107 return 0;108 }109 110 ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &forallTypes ) {111 if ( function->get_returnVals().empty() ) return 0;112 113 return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );114 }115 116 ReferenceToType *isDynRet( FunctionType *function ) {117 if ( function->get_returnVals().empty() ) return 0;118 119 TyVarMap forallTypes( (TypeDecl::Kind)-1 );120 makeTyVarMap( function, forallTypes );121 return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );122 }123 124 bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) {125 // if ( ! adaptee->get_returnVals().empty() && isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {126 // return true;127 // } // if128 if ( isDynRet( adaptee, tyVars ) ) return true;129 130 for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) {131 // if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) {132 if ( isDynType( (*innerArg)->get_type(), tyVars ) ) {133 return true;134 } // if135 } // for136 return false;137 103 } 138 104
Note:
See TracChangeset
for help on using the changeset viewer.