Changeset 084184b


Ignore:
Timestamp:
May 26, 2016, 8:12:56 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
e24955a
Parents:
d9f1b2d
Message:

Add recursive lookup for TypeInstType? to TypeSubstitution?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/TypeSubstitution.cc

    rd9f1b2d r084184b  
    7272Type *TypeSubstitution::lookup( std::string formalType ) const {
    7373        TypeEnvType::const_iterator i = typeEnv.find( formalType );
     74       
     75        // break on not in substitution set
     76        if ( i == typeEnv.end() ) return 0;
     77       
     78        // attempt to transitively follow TypeInstType links.
     79        while ( TypeInstType *actualType = dynamic_cast< TypeInstType* >( i->second ) ) {
     80                const std::string& typeName = actualType->get_name();
     81               
     82                // break cycles in the transitive follow
     83                if ( formalType == typeName ) break;
     84               
     85                // Look for the type this maps to, returning previous mapping if none-such
     86                i = typeEnv.find( typeName );
     87                if ( i == typeEnv.end() ) return actualType;
     88        }
     89       
     90        // return type from substitution set
     91        return i->second;
     92       
     93#if 0
    7494        if ( i == typeEnv.end() ) {
    7595                return 0;
     
    7797                return i->second;
    7898        } // if
     99#endif
    79100}
    80101
Note: See TracChangeset for help on using the changeset viewer.