Changeset effdde0
- Timestamp:
- Oct 2, 2017, 5:11:51 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 93fe7141
- Parents:
- d29fa5f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/FindFunction.cc
rd29fa5f reffdde0 18 18 #include <utility> // for pair 19 19 20 #include "Common/PassVisitor.h" // for PassVisitor 20 21 #include "Common/SemanticError.h" // for SemanticError 21 22 #include "GenPoly/ErasableScopedMap.h" // for ErasableScopedMap<>::iterator … … 27 28 28 29 namespace GenPoly { 29 class FindFunction : public Mutator{30 class FindFunction : public WithGuards, public WithVisitorRef<FindFunction>, public WithShortCircuiting { 30 31 public: 31 32 FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate ); 32 33 33 virtual Type *mutate( FunctionType *functionType ); 34 virtual Type *mutate( PointerType *pointerType ); 34 void premutate( FunctionType * functionType ); 35 Type * postmutate( FunctionType * functionType ); 36 void premutate( PointerType * pointerType ); 35 37 private: 36 38 void handleForall( const Type::ForallList &forall ); … … 43 45 44 46 void findFunction( Type *type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) { 45 FindFunctionfinder( functions, tyVars, false, predicate );47 PassVisitor<FindFunction> finder( functions, tyVars, false, predicate ); 46 48 type->acceptMutator( finder ); 47 49 } 48 50 49 51 void findAndReplaceFunction( Type *&type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) { 50 FindFunctionfinder( functions, tyVars, true, predicate );52 PassVisitor<FindFunction> finder( functions, tyVars, true, predicate ); 51 53 type = type->acceptMutator( finder ); 52 54 } … … 57 59 58 60 void FindFunction::handleForall( const Type::ForallList &forall ) { 59 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i) {60 TyVarMap::iterator var = tyVars.find( (*i)->get_name());61 for ( const Declaration * td : forall ) { 62 TyVarMap::iterator var = tyVars.find( td->name ); 61 63 if ( var != tyVars.end() ) { 62 64 tyVars.erase( var->first ); … … 65 67 } 66 68 67 Type * FindFunction::mutate( FunctionType *functionType ) { 68 tyVars.beginScope(); 69 void FindFunction::premutate( FunctionType * functionType ) { 70 visit_children = false; 71 GuardScope( tyVars ); 69 72 handleForall( functionType->get_forall() ); 70 mutateAll( functionType->get_returnVals(), *this ); 73 mutateAll( functionType->get_returnVals(), *visitor ); 74 } 75 76 Type * FindFunction::postmutate( FunctionType * functionType ) { 71 77 Type *ret = functionType; 72 78 if ( predicate( functionType, tyVars ) ) { … … 77 83 } // if 78 84 } // if 79 tyVars.endScope();80 85 return ret; 81 86 } 82 87 83 Type * FindFunction::mutate( PointerType *pointerType ) {84 tyVars.beginScope();88 void FindFunction::premutate( PointerType * pointerType ) { 89 GuardScope( tyVars ); 85 90 handleForall( pointerType->get_forall() ); 86 Type *ret = Mutator::mutate( pointerType );87 tyVars.endScope();88 return ret;89 91 } 90 92 } // namespace GenPoly
Note: See TracChangeset
for help on using the changeset viewer.