Changeset 7bd712d
- Timestamp:
- Jun 15, 2017, 3:33:44 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:
- 4eb31f2b
- Parents:
- 637568b (diff), 7b6ca2e (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
r637568b r7bd712d 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 { 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 ); 55 56 at_cleanup_t at_cleanup; 57 std::list< Statement * > stmtsToAddBefore; 50 58 51 59 protected: … … 129 137 130 138 void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) { 131 ReturnFixerfixer;139 PassVisitor<ReturnFixer> fixer; 132 140 mutateAll( translationUnit, fixer ); 133 141 } 134 142 135 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {143 void ReturnFixer::premutate( ReturnStmt *returnStmt ) { 136 144 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 137 145 assert( returnVals.size() == 0 || returnVals.size() == 1 ); … … 144 152 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 145 153 construct->get_args().push_back( returnStmt->get_expr() ); 146 stmtsToAdd .push_back(new ExprStmt(noLabels, construct));154 stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct)); 147 155 148 156 // return the retVal object 149 157 returnStmt->set_expr( new VariableExpr( returnVals.front() ) ); 150 158 } // if 151 return returnStmt; 152 } 153 154 DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) { 155 ValueGuard< FunctionType * > oldFtype( ftype ); 156 ValueGuard< std::string > oldFuncName( funcName ); 159 } 160 161 void ReturnFixer::premutate( FunctionDecl *functionDecl ) { 162 GuardValue( this, ftype ); 163 GuardValue( this, funcName ); 157 164 158 165 ftype = functionDecl->get_functionType(); 159 166 funcName = functionDecl->get_name(); 160 return Parent::mutate( functionDecl );161 167 } 162 168
Note: See TracChangeset
for help on using the changeset viewer.