Changes in src/GenPoly/GenPoly.cc [93c10de:c97b448]
- File:
-
- 1 edited
-
src/GenPoly/GenPoly.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/GenPoly.cc
r93c10de rc97b448 24 24 #include <vector> // for vector 25 25 26 #include "AST/Expr.hpp" 26 27 #include "AST/Type.hpp" 28 #include "AST/TypeSubstitution.hpp" 27 29 #include "GenPoly/ErasableScopedMap.h" // for ErasableScopedMap<>::const_it... 28 30 #include "ResolvExpr/typeops.h" // for flatten … … 170 172 171 173 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 172 if ( tyVars. find( typeInst->get_name() ) != tyVars.end() ) {174 if ( tyVars.contains( typeInst->get_name() ) ) { 173 175 return type; 174 176 } … … 187 189 188 190 if ( auto typeInst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 189 return tyVars.find(typeInst->typeString()) != tyVars.end() ? type : nullptr;191 if ( tyVars.contains( typeInst->typeString() ) ) return type; 190 192 } else if ( auto arrayType = dynamic_cast< const ast::ArrayType * >( type ) ) { 191 193 return isPolyType( arrayType->base, env ); … … 203 205 204 206 if ( auto inst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 205 if ( typeVars. find( *inst ) != typeVars.end() ) return type;207 if ( typeVars.contains( *inst ) ) return type; 206 208 } else if ( auto array = dynamic_cast< const ast::ArrayType * >( type ) ) { 207 209 return isPolyType( array->base, subst ); … … 272 274 return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes ); 273 275 } 276 277 const ast::BaseInstType *isDynRet( const ast::FunctionType * func ) { 278 if ( func->returns.empty() ) return nullptr; 279 280 TypeVarMap forallTypes = { ast::TypeData() }; 281 makeTypeVarMap( func, forallTypes ); 282 return isDynType( func->returns.front(), forallTypes ); 283 } 274 284 275 285 bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) { … … 317 327 return 0; 318 328 } 329 330 const ast::Type * isPolyPtr( 331 const ast::Type * type, const TypeVarMap & typeVars, 332 const ast::TypeSubstitution * typeSubs ) { 333 type = replaceTypeInst( type, typeSubs ); 334 335 if ( auto * ptr = dynamic_cast<ast::PointerType const *>( type ) ) { 336 return isPolyType( ptr->base, typeVars, typeSubs ); 337 } 338 return nullptr; 339 } 319 340 320 341 Type * hasPolyBase( Type *type, int *levels, const TypeSubstitution *env ) { … … 391 412 392 413 if ( TypeInstType *typeInstType = dynamic_cast< TypeInstType * >( type ) ) { 393 if ( tyVars. find( typeInstType->get_name() ) != tyVars.end() ) {414 if ( tyVars.contains( typeInstType->get_name() ) ) { 394 415 return true; 395 416 } … … 490 511 } 491 512 513 /// Flattens a list of types. 514 // There is another flattenList in Unify. 492 515 void flattenList( vector<ast::ptr<ast::Type>> const & src, 493 516 vector<ast::ptr<ast::Type>> & out ) { … … 792 815 } 793 816 817 void addToTypeVarMap( const ast::TypeDecl * decl, TypeVarMap & typeVars ) { 818 typeVars.insert( ast::TypeEnvKey( decl, 0, 0 ), ast::TypeData( decl ) ); 819 } 820 794 821 void addToTypeVarMap( const ast::TypeInstType * type, TypeVarMap & typeVars ) { 795 typeVars.insert( *type, ast::TypeData( type->base ) );822 typeVars.insert( ast::TypeEnvKey( *type ), ast::TypeData( type->base ) ); 796 823 } 797 824 … … 818 845 } 819 846 847 void makeTypeVarMap( const ast::FunctionDecl * decl, TypeVarMap & typeVars ) { 848 for ( auto & typeDecl : decl->type_params ) { 849 addToTypeVarMap( typeDecl, typeVars ); 850 } 851 } 852 820 853 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) { 821 854 for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
Note:
See TracChangeset
for help on using the changeset viewer.