Changeset 1bc9dcb for src/InitTweak/GenInit.cc
- Timestamp:
- Jun 16, 2017, 3:34:55 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:
- 9d85038
- Parents:
- a724ac1 (diff), d33bc7c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
ra724ac1 r1bc9dcb 16 16 #include <stack> 17 17 #include <list> 18 19 #include "InitTweak.h" 18 20 #include "GenInit.h" 19 #include "InitTweak.h" 21 22 #include "Common/PassVisitor.h" 23 20 24 #include "SynTree/Declaration.h" 21 #include "SynTree/Type.h"22 25 #include "SynTree/Expression.h" 23 #include "SynTree/Statement.h"24 26 #include "SynTree/Initializer.h" 25 27 #include "SynTree/Mutator.h" 28 #include "SynTree/Statement.h" 29 #include "SynTree/Type.h" 30 26 31 #include "SymTab/Autogen.h" 27 32 #include "SymTab/Mangler.h" 33 34 #include "GenPoly/DeclMutator.h" 28 35 #include "GenPoly/PolyMutator.h" 29 #include "GenPoly/DeclMutator.h"30 36 #include "GenPoly/ScopedSet.h" 37 31 38 #include "ResolvExpr/typeops.h" 32 39 … … 37 44 } 38 45 39 class ReturnFixer final : public GenPoly::PolyMutator{46 class ReturnFixer : public WithStmtsToAdd, public WithScopes { 40 47 public: 41 48 /// consistently allocates a temporary variable for the return value … … 44 51 static void makeReturnTemp( std::list< Declaration * > &translationUnit ); 45 52 46 typedef GenPoly::PolyMutator Parent; 47 using Parent::mutate; 48 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 49 virtual Statement * mutate( ReturnStmt * returnStmt ) override; 53 void premutate( FunctionDecl *functionDecl ); 54 void premutate( ReturnStmt * returnStmt ); 50 55 51 56 protected: … … 129 134 130 135 void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) { 131 ReturnFixerfixer;136 PassVisitor<ReturnFixer> fixer; 132 137 mutateAll( translationUnit, fixer ); 133 138 } 134 139 135 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {140 void ReturnFixer::premutate( ReturnStmt *returnStmt ) { 136 141 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 137 142 assert( returnVals.size() == 0 || returnVals.size() == 1 ); … … 144 149 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 145 150 construct->get_args().push_back( returnStmt->get_expr() ); 146 stmtsToAdd .push_back(new ExprStmt(noLabels, construct));151 stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct)); 147 152 148 153 // return the retVal object 149 154 returnStmt->set_expr( new VariableExpr( returnVals.front() ) ); 150 155 } // if 151 return returnStmt; 152 } 153 154 DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) { 155 ValueGuard< FunctionType * > oldFtype( ftype ); 156 ValueGuard< std::string > oldFuncName( funcName ); 156 } 157 158 void ReturnFixer::premutate( FunctionDecl *functionDecl ) { 159 GuardValue( ftype ); 160 GuardValue( funcName ); 157 161 158 162 ftype = functionDecl->get_functionType(); 159 163 funcName = functionDecl->get_name(); 160 return Parent::mutate( functionDecl );161 164 } 162 165
Note: See TracChangeset
for help on using the changeset viewer.