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