Changes in src/GenPoly/FindFunction.cc [effdde0:08fc48f]
- File:
-
- 1 edited
-
src/GenPoly/FindFunction.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/FindFunction.cc
reffdde0 r08fc48f 18 18 #include <utility> // for pair 19 19 20 #include "Common/PassVisitor.h" // for PassVisitor21 20 #include "Common/SemanticError.h" // for SemanticError 22 21 #include "GenPoly/ErasableScopedMap.h" // for ErasableScopedMap<>::iterator … … 28 27 29 28 namespace GenPoly { 30 class FindFunction : public WithGuards, public WithVisitorRef<FindFunction>, public WithShortCircuiting{29 class FindFunction : public Mutator { 31 30 public: 32 31 FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate ); 33 32 34 void premutate( FunctionType * functionType ); 35 Type * postmutate( FunctionType * functionType ); 36 void premutate( PointerType * pointerType ); 33 virtual Type *mutate( FunctionType *functionType ); 34 virtual Type *mutate( PointerType *pointerType ); 37 35 private: 38 36 void handleForall( const Type::ForallList &forall ); … … 45 43 46 44 void findFunction( Type *type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) { 47 PassVisitor<FindFunction>finder( functions, tyVars, false, predicate );45 FindFunction finder( functions, tyVars, false, predicate ); 48 46 type->acceptMutator( finder ); 49 47 } 50 48 51 49 void findAndReplaceFunction( Type *&type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) { 52 PassVisitor<FindFunction>finder( functions, tyVars, true, predicate );50 FindFunction finder( functions, tyVars, true, predicate ); 53 51 type = type->acceptMutator( finder ); 54 52 } … … 59 57 60 58 void FindFunction::handleForall( const Type::ForallList &forall ) { 61 for ( const Declaration * td : forall) {62 TyVarMap::iterator var = tyVars.find( td->name);59 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) { 60 TyVarMap::iterator var = tyVars.find( (*i)->get_name() ); 63 61 if ( var != tyVars.end() ) { 64 62 tyVars.erase( var->first ); … … 67 65 } 68 66 69 void FindFunction::premutate( FunctionType * functionType ) { 70 visit_children = false; 71 GuardScope( tyVars ); 67 Type * FindFunction::mutate( FunctionType *functionType ) { 68 tyVars.beginScope(); 72 69 handleForall( functionType->get_forall() ); 73 mutateAll( functionType->get_returnVals(), *visitor ); 74 } 75 76 Type * FindFunction::postmutate( FunctionType * functionType ) { 70 mutateAll( functionType->get_returnVals(), *this ); 77 71 Type *ret = functionType; 78 72 if ( predicate( functionType, tyVars ) ) { … … 83 77 } // if 84 78 } // if 79 tyVars.endScope(); 85 80 return ret; 86 81 } 87 82 88 void FindFunction::premutate( PointerType *pointerType ) {89 GuardScope( tyVars);83 Type * FindFunction::mutate( PointerType *pointerType ) { 84 tyVars.beginScope(); 90 85 handleForall( pointerType->get_forall() ); 86 Type *ret = Mutator::mutate( pointerType ); 87 tyVars.endScope(); 88 return ret; 91 89 } 92 90 } // namespace GenPoly
Note:
See TracChangeset
for help on using the changeset viewer.