Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Actors.cpp

    r2d028039 rccf1d99  
    180180};
    181181
     182#define __ALLOC 0 // C_TODO: complete swap to no-alloc version
     183
    182184struct GenReceiveDecls : public ast::WithDeclsToAdd<> {
    183185    unordered_set<const StructDecl *> & actorStructDecls;
     
    216218            /*
    217219                static inline derived_actor & ?|?( derived_actor & receiver, derived_msg & msg ) {
    218                     request new_req;
     220                    request * new_req = alloc();
    219221                    Allocation (*my_work_fn)( derived_actor &, derived_msg & ) = receive;
    220222                    __receive_fn fn = (__receive_fn)my_work_fn;
    221                     new_req{ &receiver, &msg, fn };
    222                     send( receiver, new_req );
     223                    (*new_req){ &receiver, &msg, fn };
     224                    send( receiver, *new_req );
    223225                    return receiver;
    224226                }
     
    226228            CompoundStmt * sendBody = new CompoundStmt( decl->location );
    227229
     230            #if __ALLOC
     231            // Generates: request * new_req = alloc();
     232            sendBody->push_back( new DeclStmt(
     233                decl->location,
     234                new ObjectDecl(
     235                    decl->location,
     236                    "new_req",
     237                    new PointerType( new StructInstType( *requestDecl ) ),
     238                    new SingleInit( decl->location, new UntypedExpr( decl->location, new NameExpr( decl->location, "alloc" ), {} ) )
     239                )
     240            ));
     241            #else
    228242            // Generates: request new_req;
    229243            sendBody->push_back( new DeclStmt(
     
    235249                )
    236250            ));
     251            #endif
    237252           
    238253            // Function type is: Allocation (*)( derived_actor &, derived_msg & )
     
    275290            ));
    276291
     292            #if __ALLOC
     293            // Generates: (*new_req){ &receiver, &msg, fn };
     294            sendBody->push_back( new ExprStmt(
     295                decl->location,
     296                                new UntypedExpr (
     297                    decl->location,
     298                                        new NameExpr( decl->location, "?{}" ),
     299                                        {
     300                                                new UntypedExpr( decl->location, new NameExpr( decl->location, "*?" ), {  new NameExpr( decl->location, "new_req" ) } ),
     301                        new AddressExpr( new NameExpr( decl->location, "receiver" ) ),
     302                        new AddressExpr( new NameExpr( decl->location, "msg" ) ),
     303                        new NameExpr( decl->location, "fn" )
     304                                        }
     305                                )
     306                        ));
     307
     308            // Generates: send( receiver, *new_req );
     309            sendBody->push_back( new ExprStmt(
     310                decl->location,
     311                                new UntypedExpr (
     312                    decl->location,
     313                                        new NameExpr( decl->location, "send" ),
     314                                        {
     315                                                {
     316                            new NameExpr( decl->location, "receiver" ),
     317                            new UntypedExpr( decl->location, new NameExpr( decl->location, "*?" ), {  new NameExpr( decl->location, "new_req" ) } )
     318                        }
     319                                        }
     320                                )
     321                        ));
     322            #else
    277323            // Generates: new_req{ &receiver, &msg, fn };
    278324            sendBody->push_back( new ExprStmt(
     
    304350                                )
    305351                        ));
     352            #endif
    306353           
    307354            // Generates: return receiver;
Note: See TracChangeset for help on using the changeset viewer.