Ignore:
Timestamp:
Jun 30, 2016, 4:32:56 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
ea29e73
Parents:
1b5c81ed (diff), 84d4d6f (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' into gc_noraii

Conflicts:

Jenkinsfile
src/SymTab/Validate.cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/TypeSubstitution.cc

    r1b5c81ed rf80e0218  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeSubstitution.cc -- 
     7// TypeSubstitution.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:29:15 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 26 11:15:29 2016
    1313// Update Count     : 3
    1414//
     
    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
     
    96117        BoundVarsType::const_iterator bound = boundVars.find( inst->get_name() );
    97118        if ( bound != boundVars.end() ) return inst;
    98        
     119
    99120        TypeEnvType::const_iterator i = typeEnv.find( inst->get_name() );
    100121        if ( i == typeEnv.end() ) {
     
    217238}
    218239
     240std::ostream & operator<<( std::ostream & out, const TypeSubstitution & sub ) {
     241        sub.print( out );
     242        return out;
     243}
     244
     245
    219246// Local Variables: //
    220247// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.