Ignore:
Timestamp:
Nov 14, 2022, 11:52:44 AM (3 years ago)
Author:
caparson <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
7d9598d8
Parents:
b77f0e1 (diff), 19a8c40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/GenPoly.cc

    rb77f0e1 r63be3387  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Oct  7 15:25:00 2022
    13 // Update Count     : 16
     12// Last Modified On : Mon Oct 24 15:19:00 2022
     13// Update Count     : 17
    1414//
    1515
     
    118118        }
    119119
     120        const Type* replaceTypeInst( const Type* type, const TypeSubstitution* env ) {
     121                if ( ! env ) return type;
     122                if ( auto typeInst = dynamic_cast< const TypeInstType* >( type ) ) {
     123                        Type *newType = env->lookup( typeInst->get_name() );
     124                        if ( newType ) return newType;
     125                }
     126                return type;
     127        }
     128
    120129        const ast::Type * replaceTypeInst(const ast::Type * type, const ast::TypeSubstitution * env) {
    121130                if (!env) return type;
    122                 if (auto typeInst = dynamic_cast<const ast::TypeInstType*> (type)) {
     131                if ( auto typeInst = dynamic_cast<const ast::TypeInstType*>(type) ) {
    123132                        auto newType = env->lookup(typeInst);
    124133                        if (newType) return newType;
     
    194203
    195204        if ( auto inst = dynamic_cast< const ast::TypeInstType * >( type ) ) {
    196                 if ( typeVars.find( inst->typeString() ) != typeVars.end() ) return type;
     205                if ( typeVars.find( *inst ) != typeVars.end() ) return type;
    197206        } else if ( auto array = dynamic_cast< const ast::ArrayType * >( type ) ) {
    198207                return isPolyType( array->base, subst );
     
    227236
    228237        if ( auto inst = dynamic_cast<ast::TypeInstType const *>( type ) ) {
    229                 auto var = typeVars.find( inst->name );
     238                auto var = typeVars.find( *inst );
    230239                if ( var != typeVars.end() && var->second.isComplete ) {
    231 
     240                        return inst;
    232241                }
    233242        } else if ( auto inst = dynamic_cast<ast::StructInstType const *>( type ) ) {
     
    784793
    785794void addToTypeVarMap( const ast::TypeInstType * type, TypeVarMap & typeVars ) {
    786         typeVars.insert( type->typeString(), ast::TypeDecl::Data( type->base ) );
     795        typeVars.insert( *type, ast::TypeDecl::Data( type->base ) );
    787796}
    788797
     
    816825        }
    817826
    818 void printTypeVarMap( std::ostream &os, const TypeVarMap & typeVars ) {
    819         for ( auto const & pair : typeVars ) {
    820                 os << pair.first << " (" << pair.second << ") ";
    821         } // for
    822         os << std::endl;
    823 }
    824 
    825827} // namespace GenPoly
    826828
Note: See TracChangeset for help on using the changeset viewer.