Changeset ac74057


Ignore:
Timestamp:
Sep 25, 2017, 5:05:12 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
92b3de1
Parents:
b4bfa0a
Message:

Convert AutogenTupleRoutines? to PassVisitor?

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    rb4bfa0a rac74057  
    3636#include "FixGlobalInit.h"             // for fixGlobalInit
    3737#include "GenInit.h"                   // for genCtorDtor
    38 #include "GenPoly/DeclMutator.h"       // for DeclMutator
    3938#include "GenPoly/GenPoly.h"           // for getFunctionType
    4039#include "GenPoly/PolyMutator.h"       // for PolyMutator
  • src/InitTweak/GenInit.cc

    rb4bfa0a rac74057  
    2626#include "Common/UniqueName.h"     // for UniqueName
    2727#include "Common/utility.h"        // for ValueGuard, maybeClone
    28 #include "GenPoly/DeclMutator.h"   // for DeclMutator
    2928#include "GenPoly/GenPoly.h"       // for getFunctionType, isPolyType
    3029#include "GenPoly/ScopedSet.h"     // for ScopedSet, ScopedSet<>::const_iter...
  • src/SymTab/Autogen.cc

    rb4bfa0a rac74057  
    2929#include "Common/ScopedMap.h"      // for ScopedMap<>::const_iterator, Scope...
    3030#include "Common/utility.h"        // for cloneAll, operator+
    31 #include "GenPoly/DeclMutator.h"   // for DeclMutator
    3231#include "GenPoly/ScopedSet.h"     // for ScopedSet, ScopedSet<>::iterator
    3332#include "InitTweak/GenInit.h"     // for fixReturnStatements
     
    8180
    8281        /// generates routines for tuple types.
    83         /// Doesn't really need to be a mutator, but it's easier to reuse DeclMutator than it is to use AddVisit
    84         /// or anything we currently have that supports adding new declarations for visitors
    85         class AutogenTupleRoutines : public GenPoly::DeclMutator {
    86           public:
    87                 typedef GenPoly::DeclMutator Parent;
    88                 using Parent::mutate;
    89 
    90                 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );
    91 
    92                 virtual Type * mutate( TupleType *tupleType );
    93 
    94                 virtual CompoundStmt * mutate( CompoundStmt *compoundStmt );
     82        struct AutogenTupleRoutines : public WithDeclsToAdd, public WithVisitorRef<AutogenTupleRoutines>, public WithGuards, public WithShortCircuiting {
     83                void previsit( FunctionDecl *functionDecl );
     84
     85                void postvisit( TupleType *tupleType );
     86
     87                void previsit( CompoundStmt *compoundStmt );
    9588
    9689          private:
     
    10598                // needs to be done separately because AutogenerateRoutines skips types that appear as function arguments, etc.
    10699                // AutogenTupleRoutines tupleGenerator;
    107                 // tupleGenerator.mutateDeclarationList( translationUnit );
     100                // acceptAll( translationUnit, tupleGenerator );
    108101        }
    109102
     
    707700        }
    708701
    709         Type * AutogenTupleRoutines::mutate( TupleType * tupleType ) {
    710                 tupleType = strict_dynamic_cast< TupleType * >( Parent::mutate( tupleType ) );
     702        void AutogenTupleRoutines::postvisit( TupleType * tupleType ) {
    711703                std::string mangleName = SymTab::Mangler::mangleType( tupleType );
    712                 if ( seenTuples.find( mangleName ) != seenTuples.end() ) return tupleType;
     704                if ( seenTuples.find( mangleName ) != seenTuples.end() ) return;
    713705                seenTuples.insert( mangleName );
    714706
     
    758750                makeTupleFunctionBody( dtorDecl );
    759751
    760                 addDeclaration( ctorDecl );
    761                 addDeclaration( copyCtorDecl );
    762                 addDeclaration( dtorDecl );
    763                 addDeclaration( assignDecl ); // assignment should come last since it uses copy constructor in return
    764 
    765                 return tupleType;
    766         }
    767 
    768         DeclarationWithType * AutogenTupleRoutines::mutate( FunctionDecl *functionDecl ) {
    769                 functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
     752                declsToAddBefore.push_back( ctorDecl );
     753                declsToAddBefore.push_back( copyCtorDecl );
     754                declsToAddBefore.push_back( dtorDecl );
     755                declsToAddBefore.push_back( assignDecl ); // assignment should come last since it uses copy constructor in return
     756
     757                return;
     758        }
     759
     760        void AutogenTupleRoutines::previsit( FunctionDecl *functionDecl ) {
     761                visit_children = false;
     762                functionDecl->set_functionType( maybeMutate( functionDecl->type, *visitor ) );
    770763                functionNesting += 1;
    771                 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
     764                functionDecl->set_statements( maybeMutate( functionDecl->statements, *visitor ) );
    772765                functionNesting -= 1;
    773                 return functionDecl;
    774         }
    775 
    776         CompoundStmt * AutogenTupleRoutines::mutate( CompoundStmt *compoundStmt ) {
    777                 seenTuples.beginScope();
    778                 compoundStmt = strict_dynamic_cast< CompoundStmt * >( Parent::mutate( compoundStmt ) );
    779                 seenTuples.endScope();
    780                 return compoundStmt;
     766        }
     767
     768        void AutogenTupleRoutines::previsit( CompoundStmt * ) {
     769                GuardScope( seenTuples );
    781770        }
    782771} // SymTab
  • src/Tuples/TupleExpansion.cc

    rb4bfa0a rac74057  
    2121#include "Common/ScopedMap.h"     // for ScopedMap
    2222#include "Common/utility.h"       // for CodeLocation
    23 #include "GenPoly/DeclMutator.h"  // for DeclMutator
    2423#include "InitTweak/InitTweak.h"  // for getFunction
    2524#include "Parser/LinkageSpec.h"   // for Spec, C, Intrinsic
Note: See TracChangeset for help on using the changeset viewer.