Changes in src/Concurrency/Actors.cpp [b065dbb:0794365]
- File:
-
- 1 edited
-
src/Concurrency/Actors.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Actors.cpp
rb065dbb r0794365 223 223 if ( actorIter != actorStructDecls.end() && messageIter != messageStructDecls.end() ) { 224 224 ////////////////////////////////////////////////////////////////////// 225 // The following generates this wrapper for all receive(derived_actor &, derived_msg &) functions226 /* base_actor and base_msg are output params227 static inline allocation __CFA_receive_wrap( derived_actor & receiver, derived_msg & msg, actor ** base_actor, message ** base_msg ) {228 base_actor = &receiver;229 base_msg = &msg;230 return receive( receiver, msg );231 }232 */233 CompoundStmt * wrapBody = new CompoundStmt( decl->location );234 235 // generates: base_actor = &receiver;236 wrapBody->push_back( new ExprStmt( decl->location,237 UntypedExpr::createAssign( decl->location,238 UntypedExpr::createDeref( decl->location, new NameExpr( decl->location, "base_actor" ) ),239 new AddressExpr( decl->location, new NameExpr( decl->location, "receiver" ) )240 )241 ));242 243 // generates: base_msg = &msg;244 wrapBody->push_back( new ExprStmt( decl->location,245 UntypedExpr::createAssign( decl->location,246 UntypedExpr::createDeref( decl->location, new NameExpr( decl->location, "base_msg" ) ),247 new AddressExpr( decl->location, new NameExpr( decl->location, "msg" ) )248 )249 ));250 251 // generates: return receive( receiver, msg );252 wrapBody->push_back( new ReturnStmt( decl->location,253 new UntypedExpr ( decl->location,254 new NameExpr( decl->location, "receive" ),255 {256 new NameExpr( decl->location, "receiver" ),257 new NameExpr( decl->location, "msg" )258 }259 )260 ));261 262 // create receive wrapper to extract base message and actor pointer263 // put it all together into the complete function decl from above264 FunctionDecl * receiveWrapper = new FunctionDecl(265 decl->location,266 "__CFA_receive_wrap",267 {}, // forall268 {269 new ObjectDecl(270 decl->location,271 "receiver",272 ast::deepCopy( derivedActorRef )273 ),274 new ObjectDecl(275 decl->location,276 "msg",277 ast::deepCopy( derivedMsgRef )278 ),279 new ObjectDecl(280 decl->location,281 "base_actor",282 new PointerType( new PointerType( new StructInstType( *actorDecl ) ) )283 ),284 new ObjectDecl(285 decl->location,286 "base_msg",287 new PointerType( new PointerType( new StructInstType( *msgDecl ) ) )288 )289 }, // params290 {291 new ObjectDecl(292 decl->location,293 "__CFA_receive_wrap_ret",294 new EnumInstType( *allocationDecl )295 )296 },297 wrapBody, // body298 { Storage::Static }, // storage299 Linkage::Cforall, // linkage300 {}, // attributes301 { Function::Inline }302 );303 304 declsToAddAfter.push_back( receiveWrapper );305 306 //////////////////////////////////////////////////////////////////////307 225 // The following generates this send message operator routine for all receive(derived_actor &, derived_msg &) functions 308 226 /* … … 328 246 )); 329 247 330 // Function type is: allocation (*)( derived_actor &, derived_msg & , actor **, message **)248 // Function type is: allocation (*)( derived_actor &, derived_msg & ) 331 249 FunctionType * derivedReceive = new FunctionType(); 332 250 derivedReceive->params.push_back( ast::deepCopy( derivedActorRef ) ); 333 251 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 252 derivedReceive->returns.push_back( new EnumInstType( *allocationDecl ) ); 337 253 338 // Generates: allocation (*my_work_fn)( derived_actor &, derived_msg & , actor **, message **) = receive;254 // Generates: allocation (*my_work_fn)( derived_actor &, derived_msg & ) = receive; 339 255 sendBody->push_back( new DeclStmt( 340 256 decl->location, … … 343 259 "my_work_fn", 344 260 new PointerType( derivedReceive ), 345 new SingleInit( decl->location, new NameExpr( decl->location, " __CFA_receive_wrap" ) )261 new SingleInit( decl->location, new NameExpr( decl->location, "receive" ) ) 346 262 ) 347 263 )); … … 351 267 genericReceive->params.push_back( new ReferenceType( new StructInstType( *actorDecl ) ) ); 352 268 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 269 genericReceive->returns.push_back( new EnumInstType( *allocationDecl ) ); 356 270 … … 371 285 )); 372 286 373 // Generates: new_req{ (actor *)&receiver, (message *)&msg, fn };287 // Generates: new_req{ &receiver, &msg, fn }; 374 288 sendBody->push_back( new ExprStmt( 375 289 decl->location, … … 379 293 { 380 294 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),295 new AddressExpr( new NameExpr( decl->location, "receiver" ) ), 296 new AddressExpr( new NameExpr( decl->location, "msg" ) ), 383 297 new NameExpr( decl->location, "fn" ) 384 298 } … … 407 321 FunctionDecl * sendOperatorFunction = new FunctionDecl( 408 322 decl->location, 409 "? |?",323 "?<<?", 410 324 {}, // forall 411 325 {
Note:
See TracChangeset
for help on using the changeset viewer.