Changes in src/Concurrency/Actors.cpp [1ee74df:ed96731]
- File:
-
- 1 edited
-
src/Concurrency/Actors.cpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Actors.cpp
r1ee74df red96731 29 29 struct CollectactorStructDecls : public ast::WithGuards { 30 30 unordered_set<const StructDecl *> & actorStructDecls; 31 unordered_set<const StructDecl *> & messageStructDecls;32 const StructDecl * &requestDecl;33 const EnumDecl * &allocationDecl;34 const StructDecl * &actorDecl;35 const StructDecl * &msgDecl;31 unordered_set<const StructDecl *> & messageStructDecls; 32 const StructDecl ** requestDecl; 33 const EnumDecl ** allocationDecl; 34 const StructDecl ** actorDecl; 35 const StructDecl ** msgDecl; 36 36 StructDecl * parentDecl; 37 37 bool insideStruct = false; … … 40 40 // finds and sets a ptr to the allocation enum, which is needed in the next pass 41 41 void previsit( const EnumDecl * decl ) { 42 if( decl->name == "allocation" ) allocationDecl = decl;42 if( decl->name == "allocation" ) *allocationDecl = decl; 43 43 } 44 44 … … 48 48 if ( decl->name == "actor" ) { 49 49 actorStructDecls.insert( decl ); // skip inserting fwd decl 50 actorDecl = decl;50 *actorDecl = decl; 51 51 } else if( decl->name == "message" ) { 52 52 messageStructDecls.insert( decl ); // skip inserting fwd decl 53 msgDecl = decl; 54 } else if( decl->name == "request" ) { 55 requestDecl = decl; 56 } else { 53 *msgDecl = decl; 54 } else if( decl->name == "request" ) *requestDecl = decl; 55 else { 57 56 GuardValue(insideStruct); 58 57 insideStruct = true; … … 74 73 // this collects the derived actor and message struct decl ptrs 75 74 void postvisit( const StructInstType * node ) { 76 if ( ! actorDecl || !msgDecl ) return;75 if ( ! *actorDecl || ! *msgDecl ) return; 77 76 if ( insideStruct && !namedDecl ) { 78 77 auto actorIter = actorStructDecls.find( node->aggr() ); … … 90 89 public: 91 90 CollectactorStructDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 92 const StructDecl * & requestDecl, const EnumDecl *& allocationDecl, const StructDecl *& actorDecl, const StructDecl *&msgDecl )91 const StructDecl ** requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl ** msgDecl ) 93 92 : actorStructDecls( actorStructDecls ), messageStructDecls( messageStructDecls ), requestDecl( requestDecl ), 94 93 allocationDecl( allocationDecl ), actorDecl(actorDecl), msgDecl(msgDecl) {} … … 197 196 struct GenFuncsCreateTables : public ast::WithDeclsToAdd { 198 197 unordered_set<const StructDecl *> & actorStructDecls; 199 unordered_set<const StructDecl *> & messageStructDecls;200 const StructDecl * &requestDecl;201 const EnumDecl * &allocationDecl;202 const StructDecl * &actorDecl;203 const StructDecl * &msgDecl;198 unordered_set<const StructDecl *> & messageStructDecls; 199 const StructDecl ** requestDecl; 200 const EnumDecl ** allocationDecl; 201 const StructDecl ** actorDecl; 202 const StructDecl ** msgDecl; 204 203 FwdDeclTable & forwardDecls; 205 204 … … 280 279 decl->location, 281 280 "base_actor", 282 new PointerType( new PointerType( new StructInstType( actorDecl ) ) )281 new PointerType( new PointerType( new StructInstType( *actorDecl ) ) ) 283 282 ), 284 283 new ObjectDecl( 285 284 decl->location, 286 285 "base_msg", 287 new PointerType( new PointerType( new StructInstType( msgDecl ) ) )286 new PointerType( new PointerType( new StructInstType( *msgDecl ) ) ) 288 287 ) 289 288 }, // params … … 292 291 decl->location, 293 292 "__CFA_receive_wrap_ret", 294 new EnumInstType( allocationDecl )293 new EnumInstType( *allocationDecl ) 295 294 ) 296 295 }, … … 324 323 decl->location, 325 324 "new_req", 326 new StructInstType( requestDecl )325 new StructInstType( *requestDecl ) 327 326 ) 328 327 )); … … 332 331 derivedReceive->params.push_back( ast::deepCopy( derivedActorRef ) ); 333 332 derivedReceive->params.push_back( ast::deepCopy( derivedMsgRef ) ); 334 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( actorDecl ) ) ) );335 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( msgDecl ) ) ) );336 derivedReceive->returns.push_back( new EnumInstType( allocationDecl ) );333 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *actorDecl ) ) ) ); 334 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *msgDecl ) ) ) ); 335 derivedReceive->returns.push_back( new EnumInstType( *allocationDecl ) ); 337 336 338 337 // Generates: allocation (*my_work_fn)( derived_actor &, derived_msg &, actor **, message ** ) = receive; … … 349 348 // Function type is: allocation (*)( actor &, message & ) 350 349 FunctionType * genericReceive = new FunctionType(); 351 genericReceive->params.push_back( new ReferenceType( new StructInstType( actorDecl ) ) );352 genericReceive->params.push_back( new ReferenceType( new StructInstType( msgDecl ) ) );353 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( actorDecl ) ) ) );354 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( msgDecl ) ) ) );355 genericReceive->returns.push_back( new EnumInstType( allocationDecl ) );350 genericReceive->params.push_back( new ReferenceType( new StructInstType( *actorDecl ) ) ); 351 genericReceive->params.push_back( new ReferenceType( new StructInstType( *msgDecl ) ) ); 352 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *actorDecl ) ) ) ); 353 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *msgDecl ) ) ) ); 354 genericReceive->returns.push_back( new EnumInstType( *allocationDecl ) ); 356 355 357 356 // Generates: allocation (*fn)( actor &, message & ) = (allocation (*)( actor &, message & ))my_work_fn; … … 379 378 { 380 379 new NameExpr( decl->location, "new_req" ), 381 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "receiver" ) ), new PointerType( new StructInstType( actorDecl ) ), ExplicitCast ),382 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "msg" ) ), new PointerType( new StructInstType( msgDecl ) ), ExplicitCast ),380 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "receiver" ) ), new PointerType( new StructInstType( *actorDecl ) ), ExplicitCast ), 381 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "msg" ) ), new PointerType( new StructInstType( *msgDecl ) ), ExplicitCast ), 383 382 new NameExpr( decl->location, "fn" ) 384 383 } … … 444 443 public: 445 444 GenFuncsCreateTables( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 446 const StructDecl * & requestDecl, const EnumDecl *& allocationDecl, const StructDecl *& actorDecl, const StructDecl *&msgDecl,445 const StructDecl ** requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl ** msgDecl, 447 446 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), 448 447 requestDecl(requestDecl), allocationDecl(allocationDecl), actorDecl(actorDecl), msgDecl(msgDecl), forwardDecls(forwardDecls) {} … … 454 453 struct FwdDeclOperator : public ast::WithDeclsToAdd { 455 454 unordered_set<const StructDecl *> & actorStructDecls; 456 unordered_set<const StructDecl *> & messageStructDecls;455 unordered_set<const StructDecl *> & messageStructDecls; 457 456 FwdDeclTable & forwardDecls; 458 457 … … 496 495 // for storing through the passes 497 496 // these are populated with various important struct decls 498 const StructDecl * requestDecl = nullptr; 499 const EnumDecl * allocationDecl = nullptr; 500 const StructDecl * actorDecl = nullptr; 501 const StructDecl * msgDecl = nullptr; 497 const StructDecl * requestDeclPtr = nullptr; 498 const EnumDecl * allocationDeclPtr = nullptr; 499 const StructDecl * actorDeclPtr = nullptr; 500 const StructDecl * msgDeclPtr = nullptr; 501 502 // double pointer to modify local ptrs above 503 const StructDecl ** requestDecl = &requestDeclPtr; 504 const EnumDecl ** allocationDecl = &allocationDeclPtr; 505 const StructDecl ** actorDecl = &actorDeclPtr; 506 const StructDecl ** msgDecl = &msgDeclPtr; 502 507 503 508 // first pass collects ptrs to allocation enum, request type, and generic receive fn typedef 504 509 // also populates maps of all derived actors and messages 505 Pass<CollectactorStructDecls>::run( translationUnit, actorStructDecls, messageStructDecls, 506 requestDecl,allocationDecl, actorDecl, msgDecl );510 Pass<CollectactorStructDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl, 511 allocationDecl, actorDecl, msgDecl ); 507 512 508 513 // check that we have found all the decls we need from <actor.hfa>, if not no need to run the rest of this pass 509 if ( !allocationDecl || !requestDecl || !actorDecl || !msgDecl)514 if ( !allocationDeclPtr || !requestDeclPtr || !actorDeclPtr || !msgDeclPtr ) 510 515 return; 511 516 512 517 // second pass locates all receive() routines that overload the generic receive fn 513 518 // it then generates the appropriate operator '|' send routines for the receive routines 514 Pass<GenFuncsCreateTables>::run( translationUnit, actorStructDecls, messageStructDecls, 515 requestDecl,allocationDecl, actorDecl, msgDecl, forwardDecls );519 Pass<GenFuncsCreateTables>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl, 520 allocationDecl, actorDecl, msgDecl, forwardDecls ); 516 521 517 522 // The third pass forward declares operator '|' send routines
Note:
See TracChangeset
for help on using the changeset viewer.