Changeset 02af79b0 for src/SynTree/TypeSubstitution.h
- Timestamp:
- May 9, 2019, 4:47:53 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b038fe4
- Parents:
- ec28948 (diff), db27767 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/TypeSubstitution.h
rec28948 r02af79b0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:52:24 201713 // Update Count : 312 // Last Modified On : Tue Apr 30 22:52:47 2019 13 // Update Count : 9 14 14 // 15 15 … … 19 19 #include <iosfwd> // for ostream 20 20 #include <list> // for list<>::iterator, _List_iterator 21 #include < map> // for _Rb_tree_iterator, map, map<>::val...22 #include < set> // for set21 #include <unordered_map> 22 #include <unordered_set> 23 23 #include <string> // for string, operator!= 24 24 #include <utility> // for pair … … 39 39 TypeSubstitution &operator=( const TypeSubstitution &other ); 40 40 41 template< typename SynTreeClass > int apply( SynTreeClass *&input ) ;42 template< typename SynTreeClass > int applyFree( SynTreeClass *&input ) ;41 template< typename SynTreeClass > int apply( SynTreeClass *&input ) const; 42 template< typename SynTreeClass > int applyFree( SynTreeClass *&input ) const; 43 43 44 44 void add( std::string formalType, Type *actualType ); … … 56 56 57 57 /// create a new TypeSubstitution using bindings from env containing all of the type variables in expr 58 static TypeSubstitution * newFromExpr( Expression * expr, TypeSubstitution * env );58 static TypeSubstitution * newFromExpr( Expression * expr, const TypeSubstitution * env ); 59 59 60 60 void normalize(); … … 78 78 friend class PassVisitor; 79 79 80 typedef std:: map< std::string, Type* > TypeEnvType;81 typedef std:: map< std::string, Expression* > VarEnvType;80 typedef std::unordered_map< std::string, Type * > TypeEnvType; 81 typedef std::unordered_map< std::string, Expression * > VarEnvType; 82 82 TypeEnvType typeEnv; 83 83 VarEnvType varEnv; … … 98 98 ActualIterator actualIt = actualBegin; 99 99 for ( ; formalIt != formalEnd; ++formalIt, ++actualIt ) { 100 if ( TypeDecl *formal = dynamic_cast< TypeDecl * >( *formalIt ) ) {101 if ( TypeExpr *actual = dynamic_cast< TypeExpr * >( *actualIt ) ) {100 if ( TypeDecl *formal = dynamic_cast< TypeDecl * >( *formalIt ) ) { 101 if ( TypeExpr *actual = dynamic_cast< TypeExpr * >( *actualIt ) ) { 102 102 if ( formal->get_name() != "" ) { 103 103 TypeEnvType::iterator i = typeEnv.find( formal->get_name() ); … … 130 130 // definitition must happen after PassVisitor is included so that WithGuards can be used 131 131 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter> { 132 Substituter( TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}132 Substituter( const TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {} 133 133 134 134 Type * postmutate( TypeInstType * aggregateUseType ); … … 143 143 void premutate( UnionInstType * aggregateUseType ); 144 144 145 TypeSubstitution & sub;145 const TypeSubstitution & sub; 146 146 int subCount = 0; 147 147 bool freeOnly; 148 typedef std:: set< std::string > BoundVarsType;148 typedef std::unordered_set< std::string > BoundVarsType; 149 149 BoundVarsType boundVars; 150 150 }; 151 151 152 152 template< typename SynTreeClass > 153 int TypeSubstitution::apply( SynTreeClass *&input ) {153 int TypeSubstitution::apply( SynTreeClass *&input ) const { 154 154 assert( input ); 155 155 PassVisitor<Substituter> sub( *this, false ); … … 163 163 164 164 template< typename SynTreeClass > 165 int TypeSubstitution::applyFree( SynTreeClass *&input ) {165 int TypeSubstitution::applyFree( SynTreeClass *&input ) const { 166 166 assert( input ); 167 167 PassVisitor<Substituter> sub( *this, true );
Note: See TracChangeset
for help on using the changeset viewer.