Changes in src/InitTweak/GenInit.cc [4eb31f2b:8ca3a72]
- File:
-
- 1 edited
-
src/InitTweak/GenInit.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
r4eb31f2b r8ca3a72 21 21 22 22 #include "Common/PassVisitor.h" 23 24 #include "GenPoly/DeclMutator.h" 25 #include "GenPoly/PolyMutator.h" 26 #include "GenPoly/ScopedSet.h" 27 28 #include "ResolvExpr/typeops.h" 23 29 24 30 #include "SynTree/Declaration.h" … … 32 38 #include "SymTab/Mangler.h" 33 39 34 #include "GenPoly/DeclMutator.h"35 #include "GenPoly/PolyMutator.h"36 #include "GenPoly/ScopedSet.h"37 38 #include "ResolvExpr/typeops.h"39 40 40 namespace InitTweak { 41 namespace { 42 const std::list<Label> noLabels; 43 const std::list<Expression *> noDesignators; 44 } 45 46 class ReturnFixer : public WithStmtsToAdd, public WithScopes { 41 class ReturnFixer final : public GenPoly::PolyMutator { 47 42 public: 48 43 /// consistently allocates a temporary variable for the return value … … 51 46 static void makeReturnTemp( std::list< Declaration * > &translationUnit ); 52 47 53 void premutate( FunctionDecl *functionDecl ); 54 void premutate( ReturnStmt * returnStmt ); 48 typedef GenPoly::PolyMutator Parent; 49 using Parent::mutate; 50 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 51 virtual Statement * mutate( ReturnStmt * returnStmt ) override; 55 52 56 53 protected: … … 134 131 135 132 void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) { 136 PassVisitor<ReturnFixer>fixer;133 ReturnFixer fixer; 137 134 mutateAll( translationUnit, fixer ); 138 135 } 139 136 140 void ReturnFixer::premutate( ReturnStmt *returnStmt ) {137 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) { 141 138 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 142 139 assert( returnVals.size() == 0 || returnVals.size() == 1 ); … … 149 146 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 150 147 construct->get_args().push_back( returnStmt->get_expr() ); 151 stmtsToAdd Before.push_back(new ExprStmt(noLabels, construct));148 stmtsToAdd.push_back(new ExprStmt(noLabels, construct)); 152 149 153 150 // return the retVal object 154 151 returnStmt->set_expr( new VariableExpr( returnVals.front() ) ); 155 152 } // if 156 } 157 158 void ReturnFixer::premutate( FunctionDecl *functionDecl ) { 159 GuardValue( ftype ); 160 GuardValue( funcName ); 153 return returnStmt; 154 } 155 156 DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) { 157 ValueGuard< FunctionType * > oldFtype( ftype ); 158 ValueGuard< std::string > oldFuncName( funcName ); 161 159 162 160 ftype = functionDecl->get_functionType(); 163 161 funcName = functionDecl->get_name(); 162 return Parent::mutate( functionDecl ); 164 163 } 165 164
Note:
See TracChangeset
for help on using the changeset viewer.