Changeset b0b958a


Ignore:
Timestamp:
Nov 30, 2015, 1:46:36 PM (9 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
5bf4712, cf16f94
Parents:
ed1065c
Message:

Switched InstantiateGeneric? pass over to use DeclMutator? base

Location:
src
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGeneric.cc

    red1065c rb0b958a  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // InstantiateGeneric.h --
     7// InstantiateGeneric.cc --
    88//
    99// Author           : Aaron B. Moss
     
    2121
    2222#include "InstantiateGeneric.h"
    23 #include "PolyMutator.h"
     23#include "DeclMutator.h"
    2424
    2525#include "ResolvExpr/typeops.h"
     
    138138
    139139        /// Mutator pass that replaces concrete instantiations of generic types with actual struct declarations, scoped appropriately
    140         class Instantiate : public PolyMutator {
     140        class Instantiate : public DeclMutator {
    141141                InstantiationMap instantiations;
    142142                UniqueName typeNamer;
    143143
    144144        public:
    145                 Instantiate() : instantiations(), typeNamer("_conc_") {}
    146 
    147                 /// Mutates the whole translation unit, inserting new struct declarations as appropriate
    148                 void mutateAll( std::list< Declaration* >& translationUnit );
    149                
     145                Instantiate() : DeclMutator(), instantiations(), typeNamer("_conc_") {}
     146
    150147                virtual Type* mutate( StructInstType *inst );
    151148                virtual Type* mutate( UnionInstType *inst );
     
    153150                virtual void doBeginScope();
    154151                virtual void doEndScope();
    155 
    156         private:
    157                 /// Adds a declaration to the current environment and the statements to add
    158                 void addDeclaration( AggregateDecl *decl ) {
    159                         std::list< Label > nolabels;
    160                         DeclStmt *stmt = new DeclStmt( nolabels, decl );
    161                         PolyMutator::stmtsToAdd.push_back( stmt );
    162                 }
    163152        };
    164153       
    165154        void instantiateGeneric( std::list< Declaration* >& translationUnit ) {
    166155                Instantiate instantiator;
    167 //              mutateAll( translationUnit, instantiator );
    168                 instantiator.mutateAll( translationUnit );
    169         }
    170 
    171         void Instantiate::mutateAll( std::list< Declaration* >& translationUnit ) {
    172                 // below copied and modified from Mutator.h:mutateAll()
    173                 SemanticError errors;
    174                 for ( std::list< Declaration* >::iterator decl = translationUnit.begin(); decl != translationUnit.end(); ++decl ) {
    175                         try {
    176                                 if ( *decl ) {
    177                                         *decl = dynamic_cast< Declaration* >( (*decl)->acceptMutator( *this ) );
    178                                         assert( *decl );
    179                                         // account for missing top-level declarations
    180                                         for ( std::list< Statement* >::const_iterator stmt = PolyMutator::stmtsToAdd.begin(); stmt != PolyMutator::stmtsToAdd.end(); ++stmt ) {
    181                                                 DeclStmt *declStmt = dynamic_cast< DeclStmt* >( *stmt );
    182                                                 assert( declStmt );
    183                                                 translationUnit.insert( decl, declStmt->get_decl() );
    184                                         }
    185                                         PolyMutator::stmtsToAdd.clear();
    186                                 } // if
    187                         } catch( SemanticError &e ) {
    188                                 errors.append( e );
    189                         } // try
    190                 } // for
    191                 if ( ! errors.isEmpty() ) {
    192                         throw errors;
    193                 } // if
     156                instantiator.mutateDeclarationList( translationUnit );
    194157        }
    195158
     
    225188                                                                *inst->get_baseParameters(), inst->get_parameters(),
    226189                                                                concDecl->get_members() );
    227                         addDeclaration( concDecl );
     190                        DeclMutator::addDeclaration( concDecl );
    228191                        instantiations.insert( inst, concDecl );
    229192                }
     
    252215                                                                *inst->get_baseParameters(), inst->get_parameters(),
    253216                                                                concDecl->get_members() );
    254                         addDeclaration( concDecl );
     217                        DeclMutator::addDeclaration( concDecl );
    255218                        instantiations.insert( inst, concDecl );
    256219                }
     
    262225       
    263226        void Instantiate::doBeginScope() {
     227                DeclMutator::doBeginScope();
    264228                // push a new concrete type scope
    265229                instantiations.beginScope();
     
    267231
    268232        void Instantiate::doEndScope() {
     233                DeclMutator::doEndScope();
    269234                // pop the last concrete type scope
    270235                instantiations.endScope();
  • src/GenPoly/module.mk

    red1065c rb0b958a  
    2323       GenPoly/CopyParams.cc \
    2424       GenPoly/FindFunction.cc \
    25        GenPoly/InstantiateGeneric.cc
     25       GenPoly/InstantiateGeneric.cc \
     26       GenPoly/DeclMutator.cc
  • src/Makefile.in

    red1065c rb0b958a  
    122122        GenPoly/cfa_cpp-FindFunction.$(OBJEXT) \
    123123        GenPoly/cfa_cpp-InstantiateGeneric.$(OBJEXT) \
     124        GenPoly/cfa_cpp-DeclMutator.$(OBJEXT) \
    124125        InitTweak/cfa_cpp-InitModel.$(OBJEXT) \
    125126        InitTweak/cfa_cpp-InitExpander.$(OBJEXT) \
     
    348349        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
    349350        GenPoly/CopyParams.cc GenPoly/FindFunction.cc \
    350         GenPoly/InstantiateGeneric.cc InitTweak/InitModel.cc \
    351         InitTweak/InitExpander.cc InitTweak/Mutate.cc \
    352         InitTweak/Association.cc InitTweak/RemoveInit.cc \
    353         Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \
    354         Parser/ParseNode.cc Parser/DeclarationNode.cc \
    355         Parser/ExpressionNode.cc Parser/StatementNode.cc \
    356         Parser/InitializerNode.cc Parser/TypeData.cc \
    357         Parser/LinkageSpec.cc Parser/parseutility.cc Parser/Parser.cc \
     351        GenPoly/InstantiateGeneric.cc GenPoly/DeclMutator.cc \
     352        InitTweak/InitModel.cc InitTweak/InitExpander.cc \
     353        InitTweak/Mutate.cc InitTweak/Association.cc \
     354        InitTweak/RemoveInit.cc Parser/parser.yy Parser/lex.ll \
     355        Parser/TypedefTable.cc Parser/ParseNode.cc \
     356        Parser/DeclarationNode.cc Parser/ExpressionNode.cc \
     357        Parser/StatementNode.cc Parser/InitializerNode.cc \
     358        Parser/TypeData.cc Parser/LinkageSpec.cc \
     359        Parser/parseutility.cc Parser/Parser.cc \
    358360        ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \
    359361        ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \
     
    556558        GenPoly/$(DEPDIR)/$(am__dirstamp)
    557559GenPoly/cfa_cpp-InstantiateGeneric.$(OBJEXT): GenPoly/$(am__dirstamp) \
     560        GenPoly/$(DEPDIR)/$(am__dirstamp)
     561GenPoly/cfa_cpp-DeclMutator.$(OBJEXT): GenPoly/$(am__dirstamp) \
    558562        GenPoly/$(DEPDIR)/$(am__dirstamp)
    559563InitTweak/$(am__dirstamp):
     
    785789        -rm -f GenPoly/cfa_cpp-Box.$(OBJEXT)
    786790        -rm -f GenPoly/cfa_cpp-CopyParams.$(OBJEXT)
     791        -rm -f GenPoly/cfa_cpp-DeclMutator.$(OBJEXT)
    787792        -rm -f GenPoly/cfa_cpp-FindFunction.$(OBJEXT)
    788793        -rm -f GenPoly/cfa_cpp-GenPoly.$(OBJEXT)
     
    895900@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/cfa_cpp-Box.Po@am__quote@
    896901@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/cfa_cpp-CopyParams.Po@am__quote@
     902@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/cfa_cpp-DeclMutator.Po@am__quote@
    897903@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/cfa_cpp-FindFunction.Po@am__quote@
    898904@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/cfa_cpp-GenPoly.Po@am__quote@
     
    13761382@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o GenPoly/cfa_cpp-InstantiateGeneric.obj `if test -f 'GenPoly/InstantiateGeneric.cc'; then $(CYGPATH_W) 'GenPoly/InstantiateGeneric.cc'; else $(CYGPATH_W) '$(srcdir)/GenPoly/InstantiateGeneric.cc'; fi`
    13771383
     1384GenPoly/cfa_cpp-DeclMutator.o: GenPoly/DeclMutator.cc
     1385@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/cfa_cpp-DeclMutator.o -MD -MP -MF GenPoly/$(DEPDIR)/cfa_cpp-DeclMutator.Tpo -c -o GenPoly/cfa_cpp-DeclMutator.o `test -f 'GenPoly/DeclMutator.cc' || echo '$(srcdir)/'`GenPoly/DeclMutator.cc
     1386@am__fastdepCXX_TRUE@   $(am__mv) GenPoly/$(DEPDIR)/cfa_cpp-DeclMutator.Tpo GenPoly/$(DEPDIR)/cfa_cpp-DeclMutator.Po
     1387@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='GenPoly/DeclMutator.cc' object='GenPoly/cfa_cpp-DeclMutator.o' libtool=no @AMDEPBACKSLASH@
     1388@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1389@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o GenPoly/cfa_cpp-DeclMutator.o `test -f 'GenPoly/DeclMutator.cc' || echo '$(srcdir)/'`GenPoly/DeclMutator.cc
     1390
     1391GenPoly/cfa_cpp-DeclMutator.obj: GenPoly/DeclMutator.cc
     1392@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/cfa_cpp-DeclMutator.obj -MD -MP -MF GenPoly/$(DEPDIR)/cfa_cpp-DeclMutator.Tpo -c -o GenPoly/cfa_cpp-DeclMutator.obj `if test -f 'GenPoly/DeclMutator.cc'; then $(CYGPATH_W) 'GenPoly/DeclMutator.cc'; else $(CYGPATH_W) '$(srcdir)/GenPoly/DeclMutator.cc'; fi`
     1393@am__fastdepCXX_TRUE@   $(am__mv) GenPoly/$(DEPDIR)/cfa_cpp-DeclMutator.Tpo GenPoly/$(DEPDIR)/cfa_cpp-DeclMutator.Po
     1394@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='GenPoly/DeclMutator.cc' object='GenPoly/cfa_cpp-DeclMutator.obj' libtool=no @AMDEPBACKSLASH@
     1395@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1396@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o GenPoly/cfa_cpp-DeclMutator.obj `if test -f 'GenPoly/DeclMutator.cc'; then $(CYGPATH_W) 'GenPoly/DeclMutator.cc'; else $(CYGPATH_W) '$(srcdir)/GenPoly/DeclMutator.cc'; fi`
     1397
    13781398InitTweak/cfa_cpp-InitModel.o: InitTweak/InitModel.cc
    13791399@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/cfa_cpp-InitModel.o -MD -MP -MF InitTweak/$(DEPDIR)/cfa_cpp-InitModel.Tpo -c -o InitTweak/cfa_cpp-InitModel.o `test -f 'InitTweak/InitModel.cc' || echo '$(srcdir)/'`InitTweak/InitModel.cc
Note: See TracChangeset for help on using the changeset viewer.