Changeset a0fdbd5


Ignore:
Timestamp:
Apr 28, 2016, 12:32:49 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
fea7ca7
Parents:
84bb4d9
Message:

remove RemoveInit?'s ObjectDecl? mutate which duplicates constructor calls on polymorphic objects, change name of RemoveInit? files to more accurate GenInit?

Location:
src
Files:
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r84bb4d9 ra0fdbd5  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Apr 27 17:08:44 2016
     12// Last Modified On : Thu Apr 28 12:25:14 2016
    1313// Update Count     : 30
    1414//
     
    1616#include <stack>
    1717#include <list>
    18 #include "RemoveInit.h"
     18#include "FixInit.h"
    1919#include "ResolvExpr/Resolver.h"
    2020#include "ResolvExpr/typeops.h"
  • src/InitTweak/GenInit.cc

    r84bb4d9 ra0fdbd5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // RemoveInit.cc --
     7// GenInit.cc --
    88//
    99// Author           : Rob Schluntz
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 15:09:36 2016
     12// Last Modified On : Thu Apr 28 12:26:47 2016
    1313// Update Count     : 166
    1414//
     
    1616#include <stack>
    1717#include <list>
    18 #include "RemoveInit.h"
     18#include "GenInit.h"
    1919#include "SynTree/Declaration.h"
    2020#include "SynTree/Type.h"
     
    3232        }
    3333
    34         class RemoveInit : public GenPoly::PolyMutator {
     34        class ReturnFixer : public GenPoly::PolyMutator {
    3535          public:
    36                 /// removes and replaces initialization for polymorphic value objects
    37                 /// with assignment (TODO: constructor) statements.
    38                 /// also consistently allocates a temporary variable for the return value
    39                 /// of a function so that anything which the resolver decides can be assigned
     36                /// consistently allocates a temporary variable for the return value
     37                /// of a function so that anything which the resolver decides can be constructed
    4038                /// into the return type of a function can be returned.
    41                 static void removeInitializers( std::list< Declaration * > &translationUnit );
    42 
    43                 RemoveInit();
    44 
    45                 virtual ObjectDecl * mutate( ObjectDecl *objDecl );
     39                static void makeReturnTemp( std::list< Declaration * > &translationUnit );
     40
     41                ReturnFixer();
     42
    4643                virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );
    4744
     
    7976        };
    8077
    81         void tweak( std::list< Declaration * > & translationUnit ) {
    82                 RemoveInit::removeInitializers( translationUnit );
     78        void genInit( std::list< Declaration * > & translationUnit ) {
     79                ReturnFixer::makeReturnTemp( translationUnit );
    8380                CtorDtor::generateCtorDtor( translationUnit );
    8481        }
    8582
    86         void RemoveInit::removeInitializers( std::list< Declaration * > & translationUnit ) {
    87                 RemoveInit remover;
    88                 mutateAll( translationUnit, remover );
    89         }
    90 
    91         RemoveInit::RemoveInit() : tempNamer( "_retVal" ) {}
    92 
    93         // in the case where an object has an initializer and a polymorphic type, insert an assignment immediately after the
    94         // declaration. This will (seemingly) cause the later phases to do the right thing with the assignment
    95         ObjectDecl *RemoveInit::mutate( ObjectDecl *objDecl ) {
    96                 if (objDecl->get_init() && dynamic_cast<TypeInstType*>(objDecl->get_type())) {
    97                         if (SingleInit * single = dynamic_cast<SingleInit*>(objDecl->get_init())) {
    98                                 // xxx this can be more complicated - consider ListInit
    99                                 UntypedExpr *assign = new UntypedExpr( new NameExpr( "?{}" ) );
    100                                 assign->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );
    101                                 assign->get_args().push_back( single->get_value()->clone() );
    102                                 stmtsToAddAfter.push_back(new ExprStmt(noLabels, assign));
    103                         } // if
    104                 } // if
    105                 return objDecl;
    106         }
    107 
    108         Statement *RemoveInit::mutate( ReturnStmt *returnStmt ) {
     83        void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) {
     84                ReturnFixer fixer;
     85                mutateAll( translationUnit, fixer );
     86        }
     87
     88        ReturnFixer::ReturnFixer() : tempNamer( "_retVal" ) {}
     89
     90        Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
    10991                // update for multiple return values
    11092                assert( returnVals.size() == 0 || returnVals.size() == 1 );
     
    128110        }
    129111
    130         DeclarationWithType* RemoveInit::mutate( FunctionDecl *functionDecl ) {
     112        DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    131113                std::list<DeclarationWithType*> oldReturnVals = returnVals;
    132114                std::string oldFuncName = funcName;
  • src/InitTweak/GenInit.h

    r84bb4d9 ra0fdbd5  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Jan 11 16:02:44 2016
     12// Last Modified On : Thu Apr 28 12:22:09 2016
    1313// Update Count     : 3
    1414//
    1515
    16 #ifndef REMOVE_INIT_H
    17 #define REMOVE_INIT_H
     16#ifndef GEN_INIT_H
     17#define GEN_INIT_H
    1818
    1919#include <string>
     
    2525
    2626namespace InitTweak {
    27         /// Adds assignment statements for polymorphic type initializers
    28         void tweak( std::list< Declaration * > & translationUnit );
     27        /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
     28        void genInit( std::list< Declaration * > & translationUnit );
    2929} // namespace
    3030
  • src/InitTweak/module.mk

    r84bb4d9 ra0fdbd5  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Rob Schluntz
    13 ## Last Modified On : Wed Jan 13 16:29:03 2016
     13## Last Modified On : Thu Apr 28 12:23:17 2016
    1414## Update Count     : 3
    1515###############################################################################
    1616
    17 SRC += InitTweak/RemoveInit.cc \
     17SRC += InitTweak/GenInit.cc \
    1818        InitTweak/FixInit.cc
  • src/Makefile.in

    r84bb4d9 ra0fdbd5  
    123123        GenPoly/driver_cfa_cpp-FindFunction.$(OBJEXT) \
    124124        GenPoly/driver_cfa_cpp-DeclMutator.$(OBJEXT) \
    125         InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) \
     125        InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT) \
    126126        InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT) \
    127127        Parser/driver_cfa_cpp-parser.$(OBJEXT) \
     
    347347        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
    348348        GenPoly/CopyParams.cc GenPoly/FindFunction.cc \
    349         GenPoly/DeclMutator.cc InitTweak/RemoveInit.cc \
     349        GenPoly/DeclMutator.cc InitTweak/GenInit.cc \
    350350        InitTweak/FixInit.cc Parser/parser.yy Parser/lex.ll \
    351351        Parser/TypedefTable.cc Parser/ParseNode.cc \
     
    565565        @$(MKDIR_P) InitTweak/$(DEPDIR)
    566566        @: > InitTweak/$(DEPDIR)/$(am__dirstamp)
    567 InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT): \
    568         InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)
     567InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT): InitTweak/$(am__dirstamp) \
     568        InitTweak/$(DEPDIR)/$(am__dirstamp)
    569569InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT): InitTweak/$(am__dirstamp) \
    570570        InitTweak/$(DEPDIR)/$(am__dirstamp)
     
    801801        -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT)
    802802        -rm -f InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT)
    803         -rm -f InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT)
     803        -rm -f InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT)
    804804        -rm -f Parser/driver_cfa_cpp-DeclarationNode.$(OBJEXT)
    805805        -rm -f Parser/driver_cfa_cpp-ExpressionNode.$(OBJEXT)
     
    908908@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@
    909909@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po@am__quote@
    910 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po@am__quote@
     910@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po@am__quote@
    911911@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-DeclarationNode.Po@am__quote@
    912912@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-ExpressionNode.Po@am__quote@
     
    13781378@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o GenPoly/driver_cfa_cpp-DeclMutator.obj `if test -f 'GenPoly/DeclMutator.cc'; then $(CYGPATH_W) 'GenPoly/DeclMutator.cc'; else $(CYGPATH_W) '$(srcdir)/GenPoly/DeclMutator.cc'; fi`
    13791379
    1380 InitTweak/driver_cfa_cpp-RemoveInit.o: InitTweak/RemoveInit.cc
    1381 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-RemoveInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo -c -o InitTweak/driver_cfa_cpp-RemoveInit.o `test -f 'InitTweak/RemoveInit.cc' || echo '$(srcdir)/'`InitTweak/RemoveInit.cc
    1382 @am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po
    1383 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/RemoveInit.cc' object='InitTweak/driver_cfa_cpp-RemoveInit.o' libtool=no @AMDEPBACKSLASH@
    1384 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1385 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.o `test -f 'InitTweak/RemoveInit.cc' || echo '$(srcdir)/'`InitTweak/RemoveInit.cc
    1386 
    1387 InitTweak/driver_cfa_cpp-RemoveInit.obj: InitTweak/RemoveInit.cc
    1388 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-RemoveInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi`
    1389 @am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po
    1390 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/RemoveInit.cc' object='InitTweak/driver_cfa_cpp-RemoveInit.obj' libtool=no @AMDEPBACKSLASH@
    1391 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1392 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi`
     1380InitTweak/driver_cfa_cpp-GenInit.o: InitTweak/GenInit.cc
     1381@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-GenInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo -c -o InitTweak/driver_cfa_cpp-GenInit.o `test -f 'InitTweak/GenInit.cc' || echo '$(srcdir)/'`InitTweak/GenInit.cc
     1382@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po
     1383@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/GenInit.cc' object='InitTweak/driver_cfa_cpp-GenInit.o' libtool=no @AMDEPBACKSLASH@
     1384@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1385@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-GenInit.o `test -f 'InitTweak/GenInit.cc' || echo '$(srcdir)/'`InitTweak/GenInit.cc
     1386
     1387InitTweak/driver_cfa_cpp-GenInit.obj: InitTweak/GenInit.cc
     1388@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-GenInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo -c -o InitTweak/driver_cfa_cpp-GenInit.obj `if test -f 'InitTweak/GenInit.cc'; then $(CYGPATH_W) 'InitTweak/GenInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/GenInit.cc'; fi`
     1389@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po
     1390@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/GenInit.cc' object='InitTweak/driver_cfa_cpp-GenInit.obj' libtool=no @AMDEPBACKSLASH@
     1391@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1392@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-GenInit.obj `if test -f 'InitTweak/GenInit.cc'; then $(CYGPATH_W) 'InitTweak/GenInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/GenInit.cc'; fi`
    13931393
    13941394InitTweak/driver_cfa_cpp-FixInit.o: InitTweak/FixInit.cc
  • src/main.cc

    r84bb4d9 ra0fdbd5  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 11 17:49:38 2016
     12// Last Modified On : Thu Apr 28 12:24:46 2016
    1313// Update Count     : 200
    1414//
     
    4040#include "MakeLibCfa.h"
    4141#include "InitTweak/Mutate.h"
    42 #include "InitTweak/RemoveInit.h"
     42#include "InitTweak/GenInit.h"
    4343#include "InitTweak/FixInit.h"
    4444//#include "Explain/GenProlog.h"
     
    259259                CodeGen::fixNames( translationUnit );
    260260                OPTPRINT( "tweakInit" )
    261                 InitTweak::tweak( translationUnit );
     261                InitTweak::genInit( translationUnit );
    262262
    263263                if ( libcfap ) {
Note: See TracChangeset for help on using the changeset viewer.