Changes in / [26238c1:1cb758f2]
- Location:
- src
- Files:
-
- 4 edited
-
Common/PassVisitor.h (modified) (2 diffs)
-
Common/PassVisitor.impl.h (modified) (6 diffs)
-
Concurrency/Keywords.cc (modified) (16 diffs)
-
Parser/StatementNode.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r26238c1 r1cb758f2 75 75 virtual void visit( CatchStmt *catchStmt ) override final; 76 76 virtual void visit( FinallyStmt *finallyStmt ) override final; 77 virtual void visit( WaitForStmt *waitforStmt ) override final;78 77 virtual void visit( NullStmt *nullStmt ) override final; 79 78 virtual void visit( DeclStmt *declStmt ) override final; … … 160 159 virtual Statement* mutate( ReturnStmt *returnStmt ) override final; 161 160 virtual Statement* mutate( ThrowStmt *throwStmt ) override final; 162 virtual Statement* mutate( TryStmt * tryStmt ) override final;161 virtual Statement* mutate( TryStmt *returnStmt ) override final; 163 162 virtual Statement* mutate( CatchStmt *catchStmt ) override final; 164 virtual Statement* mutate( FinallyStmt *finallyStmt ) override final; 165 virtual Statement* mutate( WaitForStmt *waitforStmt ) override final; 163 virtual Statement* mutate( FinallyStmt *catchStmt ) override final; 166 164 virtual NullStmt* mutate( NullStmt *nullStmt ) override final; 167 165 virtual Statement* mutate( DeclStmt *declStmt ) override final; -
src/Common/PassVisitor.impl.h
r26238c1 r1cb758f2 541 541 } 542 542 543 //--------------------------------------------------------------------------544 // FinallyStmt545 543 template< typename pass_type > 546 544 void PassVisitor< pass_type >::visit( FinallyStmt * node ) { … … 549 547 550 548 template< typename pass_type > 551 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {552 MUTATE_BODY( Statement, node );553 }554 555 //--------------------------------------------------------------------------556 // WaitForStmt557 template< typename pass_type >558 void PassVisitor< pass_type >::visit( WaitForStmt * node ) {559 VISIT_BODY( node );560 }561 562 template< typename pass_type >563 Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {564 MUTATE_BODY( Statement, node );565 }566 567 //--------------------------------------------------------------------------568 // NullStmt569 template< typename pass_type >570 549 void PassVisitor< pass_type >::visit( NullStmt * node ) { 571 550 VISIT_BODY( node ); … … 573 552 574 553 template< typename pass_type > 575 NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {576 MUTATE_BODY( NullStmt, node );577 }578 579 //--------------------------------------------------------------------------580 // DeclStmt581 template< typename pass_type >582 554 void PassVisitor< pass_type >::visit( DeclStmt * node ) { 583 555 VISIT_BODY( node ); … … 585 557 586 558 template< typename pass_type > 587 Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {588 MUTATE_BODY( Statement, node );589 }590 591 //--------------------------------------------------------------------------592 // ImplicitCtorDtorStmt593 template< typename pass_type >594 559 void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) { 595 560 VISIT_BODY( node ); … … 597 562 598 563 template< typename pass_type > 599 Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {600 MUTATE_BODY( Statement, node );601 }602 603 //--------------------------------------------------------------------------604 // ApplicationExpr605 template< typename pass_type >606 564 void PassVisitor< pass_type >::visit( ApplicationExpr * node ) { 607 565 VISIT_BODY( node ); 608 }609 610 template< typename pass_type >611 Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {612 MUTATE_BODY( Expression, node );613 566 } 614 567 … … 991 944 992 945 template< typename pass_type > 946 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { 947 MUTATE_BODY( Statement, node ); 948 } 949 950 template< typename pass_type > 951 NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) { 952 MUTATE_BODY( NullStmt, node ); 953 } 954 955 template< typename pass_type > 956 Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) { 957 MUTATE_BODY( Statement, node ); 958 } 959 960 template< typename pass_type > 961 Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) { 962 MUTATE_BODY( Statement, node ); 963 } 964 965 template< typename pass_type > 966 Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) { 967 MUTATE_BODY( Expression, node ); 968 } 969 970 template< typename pass_type > 993 971 Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) { 994 972 MUTATE_BODY( Expression, node ); -
src/Concurrency/Keywords.cc
r26238c1 r1cb758f2 19 19 #include <string> // for string, operator== 20 20 21 #include "Common/PassVisitor.h" // for PassVisitor22 21 #include "Common/SemanticError.h" // for SemanticError 23 22 #include "Common/utility.h" // for deleteAll, map_range … … 47 46 48 47 //============================================================================================= 49 // Pass declarations48 // Visitors declaration 50 49 //============================================================================================= 51 50 … … 59 58 // static inline NewField_t * getter_name( MyType * this ) { return &this->newField; } 60 59 // 61 class ConcurrentSueKeyword : public WithDeclsToAdd { 60 class ConcurrentSueKeyword : public Visitor { 61 protected: 62 template< typename Visitor > 63 friend void SymTab::acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor ); 62 64 public: 63 65 … … 67 69 virtual ~ConcurrentSueKeyword() {} 68 70 69 void postvisit( StructDecl * decl ); 71 using Visitor::visit; 72 virtual void visit( StructDecl * decl ) override final; 70 73 71 74 void handle( StructDecl * ); … … 83 86 bool needs_main; 84 87 88 std::list< Declaration * > declsToAdd, declsToAddAfter; 85 89 StructDecl* type_decl = nullptr; 86 90 }; … … 113 117 114 118 static void implement( std::list< Declaration * > & translationUnit ) { 115 PassVisitor< ThreadKeyword >impl;116 acceptAll( translationUnit, impl );119 ThreadKeyword impl; 120 SymTab::acceptAndAdd( translationUnit, impl ); 117 121 } 118 122 }; … … 144 148 145 149 static void implement( std::list< Declaration * > & translationUnit ) { 146 PassVisitor< CoroutineKeyword >impl;147 acceptAll( translationUnit, impl );150 CoroutineKeyword impl; 151 SymTab::acceptAndAdd( translationUnit, impl ); 148 152 } 149 153 }; … … 175 179 176 180 static void implement( std::list< Declaration * > & translationUnit ) { 177 PassVisitor< MonitorKeyword >impl;178 acceptAll( translationUnit, impl );181 MonitorKeyword impl; 182 SymTab::acceptAndAdd( translationUnit, impl ); 179 183 } 180 184 }; … … 188 192 // } } 189 193 // 190 class MutexKeyword final {194 class MutexKeyword final : public Visitor { 191 195 public: 192 196 193 void postvisit( FunctionDecl * decl ); 194 void postvisit( StructDecl * decl ); 197 using Visitor::visit; 198 virtual void visit( FunctionDecl * decl ) override final; 199 virtual void visit( StructDecl * decl ) override final; 195 200 196 201 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); … … 199 204 200 205 static void implement( std::list< Declaration * > & translationUnit ) { 201 PassVisitor< MutexKeyword >impl;206 MutexKeyword impl; 202 207 acceptAll( translationUnit, impl ); 203 208 } … … 225 230 // } } 226 231 // 227 class ThreadStarter final {232 class ThreadStarter final : public Visitor { 228 233 public: 229 234 230 void postvisit( FunctionDecl * decl ); 235 using Visitor::visit; 236 virtual void visit( FunctionDecl * decl ) override final; 231 237 232 238 void addStartStatement( FunctionDecl * decl, DeclarationWithType * param ); 233 239 234 240 static void implement( std::list< Declaration * > & translationUnit ) { 235 PassVisitor< ThreadStarter >impl;241 ThreadStarter impl; 236 242 acceptAll( translationUnit, impl ); 237 243 } … … 258 264 // Generic keyword implementation 259 265 //============================================================================================= 260 void ConcurrentSueKeyword::postvisit(StructDecl * decl) { 266 void ConcurrentSueKeyword::visit(StructDecl * decl) { 267 Visitor::visit(decl); 261 268 if( decl->get_name() == type_name && decl->has_body() ) { 262 269 assert( !type_decl ); … … 346 353 } 347 354 348 declsToAdd Before.push_back( forward );349 if( needs_main ) declsToAdd Before.push_back( main_decl );350 declsToAdd Before.push_back( get_decl );355 declsToAdd.push_back( forward ); 356 if( needs_main ) declsToAdd.push_back( main_decl ); 357 declsToAdd.push_back( get_decl ); 351 358 352 359 return get_decl; … … 398 405 //============================================================================================= 399 406 400 void MutexKeyword::postvisit(FunctionDecl* decl) { 407 void MutexKeyword::visit(FunctionDecl* decl) { 408 Visitor::visit(decl); 401 409 402 410 std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl ); … … 416 424 } 417 425 418 void MutexKeyword::postvisit(StructDecl* decl) { 426 void MutexKeyword::visit(StructDecl* decl) { 427 Visitor::visit(decl); 419 428 420 429 if( decl->get_name() == "monitor_desc" ) { … … 523 532 // General entry routine 524 533 //============================================================================================= 525 void ThreadStarter::postvisit(FunctionDecl * decl) { 534 void ThreadStarter::visit(FunctionDecl * decl) { 535 Visitor::visit(decl); 536 526 537 if( ! CodeGen::isConstructor(decl->get_name()) ) return; 527 538 -
src/Parser/StatementNode.cc
r26238c1 r1cb758f2 212 212 WaitForStmt::Target target; 213 213 target.function = maybeBuild<Expression>( targetExpr ); 214 215 ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() ); 216 targetExpr->set_next( nullptr ); 217 buildMoveList< Expression >( next, target.arguments ); 218 214 buildMoveList< Expression >( targetExpr, target.arguments ); 219 215 delete targetExpr; 220 216 … … 230 226 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) { 231 227 WaitForStmt::Target target; 228 232 229 target.function = maybeBuild<Expression>( targetExpr ); 233 234 ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() ); 235 targetExpr->set_next( nullptr ); 236 buildMoveList< Expression >( next, target.arguments ); 237 230 buildMoveList< Expression >( targetExpr, target.arguments ); 238 231 delete targetExpr; 239 232
Note:
See TracChangeset
for help on using the changeset viewer.