Changeset a32b204 for translator/SynTree/TypeSubstitution.cc
- Timestamp:
- May 17, 2015, 1:19:35 PM (9 years ago)
- 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, string, with_gc
- Children:
- 0dd3a2f
- Parents:
- b87a5ed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SynTree/TypeSubstitution.cc
rb87a5ed ra32b204 21 21 TypeSubstitution::~TypeSubstitution() 22 22 { 23 for ( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {23 for ( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) { 24 24 delete( i->second ); 25 25 } 26 for ( VarEnvType::iterator i = varEnv.begin(); i != varEnv.end(); ++i ) {26 for ( VarEnvType::iterator i = varEnv.begin(); i != varEnv.end(); ++i ) { 27 27 delete( i->second ); 28 28 } … … 32 32 TypeSubstitution::operator=( const TypeSubstitution &other ) 33 33 { 34 if ( this == &other ) return *this;34 if ( this == &other ) return *this; 35 35 initialize( other, *this ); 36 36 return *this; … … 48 48 TypeSubstitution::add( const TypeSubstitution &other ) 49 49 { 50 for ( TypeEnvType::const_iterator i = other.typeEnv.begin(); i != other.typeEnv.end(); ++i ) {50 for ( TypeEnvType::const_iterator i = other.typeEnv.begin(); i != other.typeEnv.end(); ++i ) { 51 51 typeEnv[ i->first ] = i->second->clone(); 52 52 } 53 for ( VarEnvType::const_iterator i = other.varEnv.begin(); i != other.varEnv.end(); ++i ) {53 for ( VarEnvType::const_iterator i = other.varEnv.begin(); i != other.varEnv.end(); ++i ) { 54 54 varEnv[ i->first ] = i->second->clone(); 55 55 } … … 60 60 { 61 61 TypeEnvType::iterator i = typeEnv.find( formalType ); 62 if ( i != typeEnv.end() ) {62 if ( i != typeEnv.end() ) { 63 63 delete i->second; 64 64 } … … 70 70 { 71 71 TypeEnvType::iterator i = typeEnv.find( formalType ); 72 if ( i != typeEnv.end() ) {72 if ( i != typeEnv.end() ) { 73 73 delete i->second; 74 74 typeEnv.erase( formalType ); … … 80 80 { 81 81 TypeEnvType::const_iterator i = typeEnv.find( formalType ); 82 if ( i == typeEnv.end() ) {82 if ( i == typeEnv.end() ) { 83 83 return 0; 84 84 } else { … … 99 99 subCount = 0; 100 100 freeOnly = true; 101 for ( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {101 for ( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) { 102 102 i->second = i->second->acceptMutator( *this ); 103 103 } 104 } while ( subCount );104 } while ( subCount ); 105 105 } 106 106 … … 109 109 { 110 110 BoundVarsType::const_iterator bound = boundVars.find( inst->get_name() ); 111 if ( bound != boundVars.end() ) return inst;111 if ( bound != boundVars.end() ) return inst; 112 112 113 113 TypeEnvType::const_iterator i = typeEnv.find( inst->get_name() ); 114 if ( i == typeEnv.end() ) {114 if ( i == typeEnv.end() ) { 115 115 return inst; 116 116 } else { … … 130 130 { 131 131 VarEnvType::const_iterator i = varEnv.find( nameExpr->get_name() ); 132 if ( i == varEnv.end() ) {132 if ( i == varEnv.end() ) { 133 133 return nameExpr; 134 134 } else { … … 144 144 { 145 145 BoundVarsType oldBoundVars( boundVars ); 146 if ( freeOnly ) {147 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {146 if ( freeOnly ) { 147 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 148 148 boundVars.insert( (*tyvar)->get_name() ); 149 149 } … … 218 218 { 219 219 os << std::string( indent, ' ' ) << "Types:" << std::endl; 220 for ( TypeEnvType::const_iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {220 for ( TypeEnvType::const_iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) { 221 221 os << std::string( indent+2, ' ' ) << i->first << " -> "; 222 222 i->second->print( os, indent+4 ); … … 224 224 } 225 225 os << std::string( indent, ' ' ) << "Non-types:" << std::endl; 226 for ( VarEnvType::const_iterator i = varEnv.begin(); i != varEnv.end(); ++i ) {226 for ( VarEnvType::const_iterator i = varEnv.begin(); i != varEnv.end(); ++i ) { 227 227 os << std::string( indent+2, ' ' ) << i->first << " -> "; 228 228 i->second->print( os, indent+4 );
Note: See TracChangeset
for help on using the changeset viewer.