Changes in src/Concurrency/Actors.cpp [3830c84:046ba23]
- File:
-
- 1 edited
-
src/Concurrency/Actors.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Actors.cpp
r3830c84 r046ba23 45 45 // finds and sets a ptr to the actor, message, and request structs, which are needed in the next pass 46 46 void previsit( const StructDecl * decl ) { 47 if ( !decl->body ) return; 48 if ( decl->name == "actor" ) { 49 actorStructDecls.insert( decl ); // skip inserting fwd decl 47 GuardValue(insideStruct); 48 insideStruct = true; 49 parentDecl = mutate( decl ); 50 if( decl->name == "actor" ) { 51 if ( actorDecl ) actorStructDecls.insert( decl ); // skip inserting fwd decl 50 52 *actorDecl = decl; 51 } else if( decl->name == "message" ) { 52 messageStructDecls.insert( decl ); // skip inserting fwd decl 53 } 54 if( decl->name == "message" ) { 55 if ( msgDecl ) messageStructDecls.insert( decl ); // skip inserting fwd decl 53 56 *msgDecl = decl; 54 } else if( decl->name == "request" ) *requestDecl = decl; 55 else { 56 GuardValue(insideStruct); 57 insideStruct = true; 58 parentDecl = mutate( decl ); 59 } 57 } 58 if( decl->name == "request" ) *requestDecl = decl; 60 59 } 61 60 … … 71 70 } 72 71 73 // this collects the derived actor and message struct decl ptrs72 // this collects the valid actor and message struct decl pts 74 73 void postvisit( const StructInstType * node ) { 75 74 if ( ! *actorDecl || ! *msgDecl ) return; 76 75 if ( insideStruct && !namedDecl ) { 77 auto actorIter = actorStructDecls.find( node->aggr() ); 78 if ( actorIter != actorStructDecls.end() ) { 76 if ( node->aggr() == *actorDecl ) { 79 77 actorStructDecls.insert( parentDecl ); 80 return; 81 } 82 auto messageIter = messageStructDecls.find( node->aggr() ); 83 if ( messageIter != messageStructDecls.end() ) { 78 } else if ( node->aggr() == *msgDecl ) { 84 79 messageStructDecls.insert( parentDecl ); 85 80 } … … 191 186 }; 192 187 193 // generates the definitions of send operators for actors 194 // collects data needed for next pass that does the circular defn resolution 195 // for message send operators (via table above) 196 struct GenFuncsCreateTables : public ast::WithDeclsToAdd<> { 188 struct GenReceiveDecls : public ast::WithDeclsToAdd<> { 197 189 unordered_set<const StructDecl *> & actorStructDecls; 198 190 unordered_set<const StructDecl *> & messageStructDecls; … … 203 195 FwdDeclTable & forwardDecls; 204 196 205 // generates the operator for actor message sends206 197 void postvisit( const FunctionDecl * decl ) { 207 198 // return if not of the form receive( param1, param2 ) or if it is a forward decl … … 222 213 auto messageIter = messageStructDecls.find( arg2InstType->aggr() ); 223 214 if ( actorIter != actorStructDecls.end() && messageIter != messageStructDecls.end() ) { 215 216 // check that we have found all the decls we need from <actor.hfa> 217 if ( !*allocationDecl || !*requestDecl ) 218 SemanticError( decl->location, "using actors requires a header, add #include <actor.hfa>\n" ); 219 224 220 ////////////////////////////////////////////////////////////////////// 225 221 // The following generates this send message operator routine for all receive(derived_actor &, derived_msg &) functions … … 351 347 // forward decls to resolve use before decl problem for '|' routines 352 348 forwardDecls.insertDecl( *actorIter, *messageIter , ast::deepCopy( sendOperatorFunction ) ); 349 // forwardDecls.push_back( ast::deepCopy( sendOperatorFunction ) ); 353 350 354 351 sendOperatorFunction->stmts = sendBody; … … 358 355 359 356 public: 360 Gen FuncsCreateTables( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,357 GenReceiveDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 361 358 const StructDecl ** requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl ** msgDecl, 362 359 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), … … 364 361 }; 365 362 366 367 // separate pass is needed since this pass resolves circular defn issues 368 // generates the forward declarations of the send operator for actor routines 369 struct FwdDeclOperator : public ast::WithDeclsToAdd<> { 363 struct GenFwdDecls : public ast::WithDeclsToAdd<> { 370 364 unordered_set<const StructDecl *> & actorStructDecls; 371 365 unordered_set<const StructDecl *> & messageStructDecls; 372 366 FwdDeclTable & forwardDecls; 373 367 374 // handles forward declaring the message operator375 368 void postvisit( const StructDecl * decl ) { 376 369 list<FunctionDecl *> toAddAfter; … … 399 392 400 393 public: 401 FwdDeclOperator( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 402 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), forwardDecls(forwardDecls) {} 394 GenFwdDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 395 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), 396 forwardDecls(forwardDecls) {} 403 397 }; 404 398 … … 426 420 Pass<CollectactorStructDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl, 427 421 allocationDecl, actorDecl, msgDecl ); 428 429 // check that we have found all the decls we need from <actor.hfa>, if not no need to run the rest of this pass 430 if ( !allocationDeclPtr || !requestDeclPtr || !actorDeclPtr || !msgDeclPtr ) 431 return; 432 422 433 423 // second pass locates all receive() routines that overload the generic receive fn 434 424 // it then generates the appropriate operator '|' send routines for the receive routines 435 Pass<Gen FuncsCreateTables>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl,425 Pass<GenReceiveDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl, 436 426 allocationDecl, actorDecl, msgDecl, forwardDecls ); 437 427 438 428 // The third pass forward declares operator '|' send routines 439 Pass< FwdDeclOperator>::run( translationUnit, actorStructDecls, messageStructDecls, forwardDecls );429 Pass<GenFwdDecls>::run( translationUnit, actorStructDecls, messageStructDecls, forwardDecls ); 440 430 } 441 431
Note:
See TracChangeset
for help on using the changeset viewer.