Changes in src/SymTab/Validate.cc [630a82a:4040425]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r630a82a r4040425 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Apr 7 16:45:30201613 // Update Count : 2 4312 // Last Modified On : Wed Mar 2 17:31:39 2016 13 // Update Count : 226 14 14 // 15 15 … … 40 40 #include <list> 41 41 #include <iterator> 42 #include "Common/utility.h"43 #include "Common/UniqueName.h"44 42 #include "Validate.h" 45 43 #include "SynTree/Visitor.h" 46 44 #include "SynTree/Mutator.h" 47 45 #include "SynTree/Type.h" 48 #include "SynTree/Expression.h"49 46 #include "SynTree/Statement.h" 50 47 #include "SynTree/TypeSubstitution.h" … … 52 49 #include "FixFunction.h" 53 50 // #include "ImplementationType.h" 54 #include "GenPoly/DeclMutator.h" 51 #include "Common/utility.h" 52 #include "Common/UniqueName.h" 55 53 #include "AddVisit.h" 56 54 #include "MakeLibCfa.h" … … 72 70 73 71 virtual void visit( CompoundStmt *compoundStmt ); 72 virtual void visit( IfStmt *ifStmt ); 73 virtual void visit( WhileStmt *whileStmt ); 74 virtual void visit( ForStmt *forStmt ); 74 75 virtual void visit( SwitchStmt *switchStmt ); 75 76 virtual void visit( ChooseStmt *chooseStmt ); 76 // virtual void visit( CaseStmt *caseStmt ); 77 virtual void visit( CaseStmt *caseStmt ); 78 virtual void visit( CatchStmt *catchStmt ); 77 79 private: 78 80 HoistStruct(); … … 142 144 143 145 virtual void visit( CompoundStmt *compoundStmt ); 146 virtual void visit( IfStmt *ifStmt ); 147 virtual void visit( WhileStmt *whileStmt ); 148 virtual void visit( ForStmt *forStmt ); 144 149 virtual void visit( SwitchStmt *switchStmt ); 145 150 virtual void visit( ChooseStmt *chooseStmt ); 146 // virtual void visit( CaseStmt *caseStmt ); 151 virtual void visit( CaseStmt *caseStmt ); 152 virtual void visit( CatchStmt *catchStmt ); 147 153 148 154 AutogenerateRoutines() : functionNesting( 0 ) {} … … 160 166 /// and return something if the return type is non-void. 161 167 static void checkFunctionReturns( std::list< Declaration * > & translationUnit ); 168 162 169 private: 163 170 virtual void visit( FunctionDecl * functionDecl ); … … 195 202 }; 196 203 197 class CompoundLiteral : public GenPoly::DeclMutator {198 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;199 200 virtual DeclarationWithType * mutate( ObjectDecl *objectDecl );201 virtual Expression *mutate( CompoundLiteralExpr *compLitExpr );202 };203 204 204 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 205 205 Pass1 pass1; 206 206 Pass2 pass2( doDebug, 0 ); 207 207 Pass3 pass3( 0 ); 208 CompoundLiteral compoundliteral;209 210 208 EliminateTypedef::eliminateTypedef( translationUnit ); 211 209 HoistStruct::hoistStruct( translationUnit ); … … 213 211 acceptAll( translationUnit, pass2 ); 214 212 ReturnChecker::checkFunctionReturns( translationUnit ); 215 mutateAll( translationUnit, compoundliteral );216 213 AutogenerateRoutines::autogenerateRoutines( translationUnit ); 217 214 acceptAll( translationUnit, pass3 ); … … 295 292 } 296 293 294 void HoistStruct::visit( IfStmt *ifStmt ) { 295 addVisit( ifStmt, *this ); 296 } 297 298 void HoistStruct::visit( WhileStmt *whileStmt ) { 299 addVisit( whileStmt, *this ); 300 } 301 302 void HoistStruct::visit( ForStmt *forStmt ) { 303 addVisit( forStmt, *this ); 304 } 305 297 306 void HoistStruct::visit( SwitchStmt *switchStmt ) { 298 307 addVisit( switchStmt, *this ); … … 303 312 } 304 313 305 // void HoistStruct::visit( CaseStmt *caseStmt ) { 306 // addVisit( caseStmt, *this ); 307 // } 314 void HoistStruct::visit( CaseStmt *caseStmt ) { 315 addVisit( caseStmt, *this ); 316 } 317 318 void HoistStruct::visit( CatchStmt *cathStmt ) { 319 addVisit( cathStmt, *this ); 320 } 308 321 309 322 void Pass1::visit( EnumDecl *enumDecl ) { … … 861 874 } 862 875 876 void AutogenerateRoutines::visit( IfStmt *ifStmt ) { 877 visitStatement( ifStmt ); 878 } 879 880 void AutogenerateRoutines::visit( WhileStmt *whileStmt ) { 881 visitStatement( whileStmt ); 882 } 883 884 void AutogenerateRoutines::visit( ForStmt *forStmt ) { 885 visitStatement( forStmt ); 886 } 887 863 888 void AutogenerateRoutines::visit( SwitchStmt *switchStmt ) { 864 889 visitStatement( switchStmt ); … … 869 894 } 870 895 871 // void AutogenerateRoutines::visit( CaseStmt *caseStmt ) { 872 // visitStatement( caseStmt ); 873 // } 896 void AutogenerateRoutines::visit( CaseStmt *caseStmt ) { 897 visitStatement( caseStmt ); 898 } 899 900 void AutogenerateRoutines::visit( CatchStmt *cathStmt ) { 901 visitStatement( cathStmt ); 902 } 874 903 875 904 void ReturnChecker::checkFunctionReturns( std::list< Declaration * > & translationUnit ) { … … 1051 1080 } 1052 1081 1053 DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) {1054 storageclass = objectDecl->get_storageClass();1055 DeclarationWithType * temp = Mutator::mutate( objectDecl );1056 storageclass = DeclarationNode::NoStorageClass;1057 return temp;1058 }1059 1060 Expression *CompoundLiteral::mutate( CompoundLiteralExpr *compLitExpr ) {1061 // transform [storage_class] ... (struct S){ 3, ... };1062 // into [storage_class] struct S temp = { 3, ... };1063 static UniqueName indexName( "_compLit" );1064 1065 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageclass, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() );1066 compLitExpr->set_type( 0 );1067 compLitExpr->set_initializer( 0 );1068 delete compLitExpr;1069 DeclarationWithType * newtempvar = mutate( tempvar );1070 addDeclaration( newtempvar ); // add modified temporary to current block1071 return new VariableExpr( newtempvar );1072 }1073 1082 } // namespace SymTab 1074 1083
Note:
See TracChangeset
for help on using the changeset viewer.