Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/FindFunction.cc

    reffdde0 r08fc48f  
    1818#include <utility>                      // for pair
    1919
    20 #include "Common/PassVisitor.h"         // for PassVisitor
    2120#include "Common/SemanticError.h"       // for SemanticError
    2221#include "GenPoly/ErasableScopedMap.h"  // for ErasableScopedMap<>::iterator
     
    2827
    2928namespace GenPoly {
    30         class FindFunction : public WithGuards, public WithVisitorRef<FindFunction>, public WithShortCircuiting {
     29        class FindFunction : public Mutator {
    3130          public:
    3231                FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate );
    3332
    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 );
    3735          private:
    3836                void handleForall( const Type::ForallList &forall );
     
    4543
    4644        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 );
    4846                type->acceptMutator( finder );
    4947        }
    5048
    5149        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 );
    5351                type = type->acceptMutator( finder );
    5452        }
     
    5957
    6058        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() );
    6361                        if ( var != tyVars.end() ) {
    6462                                tyVars.erase( var->first );
     
    6765        }
    6866
    69         void FindFunction::premutate( FunctionType * functionType ) {
    70                 visit_children = false;
    71                 GuardScope( tyVars );
     67        Type * FindFunction::mutate( FunctionType *functionType ) {
     68                tyVars.beginScope();
    7269                handleForall( functionType->get_forall() );
    73                 mutateAll( functionType->get_returnVals(), *visitor );
    74         }
    75 
    76         Type * FindFunction::postmutate( FunctionType * functionType ) {
     70                mutateAll( functionType->get_returnVals(), *this );
    7771                Type *ret = functionType;
    7872                if ( predicate( functionType, tyVars ) ) {
     
    8377                        } // if
    8478                } // if
     79                tyVars.endScope();
    8580                return ret;
    8681        }
    8782
    88         void FindFunction::premutate( PointerType * pointerType ) {
    89                 GuardScope( tyVars );
     83        Type * FindFunction::mutate( PointerType *pointerType ) {
     84                tyVars.beginScope();
    9085                handleForall( pointerType->get_forall() );
     86                Type *ret = Mutator::mutate( pointerType );
     87                tyVars.endScope();
     88                return ret;
    9189        }
    9290} // namespace GenPoly
Note: See TracChangeset for help on using the changeset viewer.