Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/GenPoly.cc

    rc97b448 r93c10de  
    2424#include <vector>                       // for vector
    2525
    26 #include "AST/Expr.hpp"
    2726#include "AST/Type.hpp"
    28 #include "AST/TypeSubstitution.hpp"
    2927#include "GenPoly/ErasableScopedMap.h"  // for ErasableScopedMap<>::const_it...
    3028#include "ResolvExpr/typeops.h"         // for flatten
     
    172170
    173171                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
    174                         if ( tyVars.contains( typeInst->get_name() ) ) {
     172                        if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) {
    175173                                return type;
    176174                        }
     
    189187
    190188                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;
    192190                } else if ( auto arrayType = dynamic_cast< const ast::ArrayType * >( type ) ) {
    193191                        return isPolyType( arrayType->base, env );
     
    205203
    206204        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;
    208206        } else if ( auto array = dynamic_cast< const ast::ArrayType * >( type ) ) {
    209207                return isPolyType( array->base, subst );
     
    274272                return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
    275273        }
    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 }
    284274
    285275        bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) {
     
    327317                return 0;
    328318        }
    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 }
    340319
    341320        Type * hasPolyBase( Type *type, int *levels, const TypeSubstitution *env ) {
     
    412391
    413392                if ( TypeInstType *typeInstType = dynamic_cast< TypeInstType * >( type ) ) {
    414                         if ( tyVars.contains( typeInstType->get_name() ) ) {
     393                        if ( tyVars.find( typeInstType->get_name() ) != tyVars.end() ) {
    415394                                return true;
    416395                        }
     
    511490                }
    512491
    513                 /// Flattens a list of types.
    514                 // There is another flattenList in Unify.
    515492                void flattenList( vector<ast::ptr<ast::Type>> const & src,
    516493                                vector<ast::ptr<ast::Type>> & out ) {
     
    815792        }
    816793
    817 void addToTypeVarMap( const ast::TypeDecl * decl, TypeVarMap & typeVars ) {
    818         typeVars.insert( ast::TypeEnvKey( decl, 0, 0 ), ast::TypeData( decl ) );
    819 }
    820 
    821794void 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 ) );
    823796}
    824797
     
    845818}
    846819
    847 void makeTypeVarMap( const ast::FunctionDecl * decl, TypeVarMap & typeVars ) {
    848         for ( auto & typeDecl : decl->type_params ) {
    849                 addToTypeVarMap( typeDecl, typeVars );
    850         }
    851 }
    852 
    853820        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) {
    854821                for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
Note: See TracChangeset for help on using the changeset viewer.