Changeset afce1cf for src/Concurrency/Keywords.cc
- Timestamp:
- Aug 28, 2017, 3:44: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:
- 39c7fd0
- Parents:
- 193bba0 (diff), 26238c1 (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/Concurrency/Keywords.cc
r193bba0 rafce1cf 19 19 #include <string> // for string, operator== 20 20 21 #include "Common/PassVisitor.h" // for PassVisitor 21 22 #include "Common/SemanticError.h" // for SemanticError 22 23 #include "Common/utility.h" // for deleteAll, map_range … … 46 47 47 48 //============================================================================================= 48 // Visitors declaration49 // Pass declarations 49 50 //============================================================================================= 50 51 … … 58 59 // static inline NewField_t * getter_name( MyType * this ) { return &this->newField; } 59 60 // 60 class ConcurrentSueKeyword : public Visitor { 61 protected: 62 template< typename Visitor > 63 friend void SymTab::acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor ); 61 class ConcurrentSueKeyword : public WithDeclsToAdd { 64 62 public: 65 63 … … 69 67 virtual ~ConcurrentSueKeyword() {} 70 68 71 using Visitor::visit; 72 virtual void visit( StructDecl * decl ) override final; 69 void postvisit( StructDecl * decl ); 73 70 74 71 void handle( StructDecl * ); … … 86 83 bool needs_main; 87 84 88 std::list< Declaration * > declsToAdd, declsToAddAfter;89 85 StructDecl* type_decl = nullptr; 90 86 }; … … 117 113 118 114 static void implement( std::list< Declaration * > & translationUnit ) { 119 ThreadKeywordimpl;120 SymTab::acceptAndAdd( translationUnit, impl );115 PassVisitor< ThreadKeyword > impl; 116 acceptAll( translationUnit, impl ); 121 117 } 122 118 }; … … 148 144 149 145 static void implement( std::list< Declaration * > & translationUnit ) { 150 CoroutineKeywordimpl;151 SymTab::acceptAndAdd( translationUnit, impl );146 PassVisitor< CoroutineKeyword > impl; 147 acceptAll( translationUnit, impl ); 152 148 } 153 149 }; … … 179 175 180 176 static void implement( std::list< Declaration * > & translationUnit ) { 181 MonitorKeywordimpl;182 SymTab::acceptAndAdd( translationUnit, impl );177 PassVisitor< MonitorKeyword > impl; 178 acceptAll( translationUnit, impl ); 183 179 } 184 180 }; … … 192 188 // } } 193 189 // 194 class MutexKeyword final : public Visitor{190 class MutexKeyword final { 195 191 public: 196 192 197 using Visitor::visit; 198 virtual void visit( FunctionDecl * decl ) override final; 199 virtual void visit( StructDecl * decl ) override final; 193 void postvisit( FunctionDecl * decl ); 194 void postvisit( StructDecl * decl ); 200 195 201 196 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); … … 204 199 205 200 static void implement( std::list< Declaration * > & translationUnit ) { 206 MutexKeywordimpl;201 PassVisitor< MutexKeyword > impl; 207 202 acceptAll( translationUnit, impl ); 208 203 } … … 230 225 // } } 231 226 // 232 class ThreadStarter final : public Visitor{227 class ThreadStarter final { 233 228 public: 234 229 235 using Visitor::visit; 236 virtual void visit( FunctionDecl * decl ) override final; 230 void postvisit( FunctionDecl * decl ); 237 231 238 232 void addStartStatement( FunctionDecl * decl, DeclarationWithType * param ); 239 233 240 234 static void implement( std::list< Declaration * > & translationUnit ) { 241 ThreadStarterimpl;235 PassVisitor< ThreadStarter > impl; 242 236 acceptAll( translationUnit, impl ); 243 237 } … … 264 258 // Generic keyword implementation 265 259 //============================================================================================= 266 void ConcurrentSueKeyword::visit(StructDecl * decl) { 267 Visitor::visit(decl); 260 void ConcurrentSueKeyword::postvisit(StructDecl * decl) { 268 261 if( decl->get_name() == type_name && decl->has_body() ) { 269 262 assert( !type_decl ); … … 353 346 } 354 347 355 declsToAdd .push_back( forward );356 if( needs_main ) declsToAdd .push_back( main_decl );357 declsToAdd .push_back( get_decl );348 declsToAddBefore.push_back( forward ); 349 if( needs_main ) declsToAddBefore.push_back( main_decl ); 350 declsToAddBefore.push_back( get_decl ); 358 351 359 352 return get_decl; … … 405 398 //============================================================================================= 406 399 407 void MutexKeyword::visit(FunctionDecl* decl) { 408 Visitor::visit(decl); 400 void MutexKeyword::postvisit(FunctionDecl* decl) { 409 401 410 402 std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl ); … … 424 416 } 425 417 426 void MutexKeyword::visit(StructDecl* decl) { 427 Visitor::visit(decl); 418 void MutexKeyword::postvisit(StructDecl* decl) { 428 419 429 420 if( decl->get_name() == "monitor_desc" ) { … … 532 523 // General entry routine 533 524 //============================================================================================= 534 void ThreadStarter::visit(FunctionDecl * decl) { 535 Visitor::visit(decl); 536 525 void ThreadStarter::postvisit(FunctionDecl * decl) { 537 526 if( ! CodeGen::isConstructor(decl->get_name()) ) return; 538 527
Note: See TracChangeset
for help on using the changeset viewer.