Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Actors.cpp

    r1ee74df red96731  
    2929struct CollectactorStructDecls : public ast::WithGuards {
    3030        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;
    3636        StructDecl * parentDecl;
    3737        bool insideStruct = false;
     
    4040        // finds and sets a ptr to the allocation enum, which is needed in the next pass
    4141        void previsit( const EnumDecl * decl ) {
    42                 if( decl->name == "allocation" ) allocationDecl = decl;
     42                if( decl->name == "allocation" ) *allocationDecl = decl;
    4343        }
    4444
     
    4848                if ( decl->name == "actor" ) {
    4949                        actorStructDecls.insert( decl ); // skip inserting fwd decl
    50                         actorDecl = decl;
     50                        *actorDecl = decl;
    5151                } else if( decl->name == "message" ) {
    5252                        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 {
    5756                        GuardValue(insideStruct);
    5857                        insideStruct = true;
     
    7473        // this collects the derived actor and message struct decl ptrs
    7574        void postvisit( const StructInstType * node ) {
    76                 if ( !actorDecl || !msgDecl ) return;
     75                if ( ! *actorDecl || ! *msgDecl ) return;
    7776                if ( insideStruct && !namedDecl ) {
    7877                        auto actorIter = actorStructDecls.find( node->aggr() );
     
    9089  public:
    9190        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 )
    9392                : actorStructDecls( actorStructDecls ), messageStructDecls( messageStructDecls ), requestDecl( requestDecl ),
    9493                allocationDecl( allocationDecl ), actorDecl(actorDecl), msgDecl(msgDecl) {}
     
    197196struct GenFuncsCreateTables : public ast::WithDeclsToAdd {
    198197        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;
    204203        FwdDeclTable & forwardDecls;
    205204
     
    280279                                                decl->location,
    281280                                                "base_actor",
    282                                                 new PointerType( new PointerType( new StructInstType( actorDecl ) ) )
     281                                                new PointerType( new PointerType( new StructInstType( *actorDecl ) ) )
    283282                                        ),
    284283                                        new ObjectDecl(
    285284                                                decl->location,
    286285                                                "base_msg",
    287                                                 new PointerType( new PointerType( new StructInstType( msgDecl ) ) )
     286                                                new PointerType( new PointerType( new StructInstType( *msgDecl ) ) )
    288287                                        )
    289288                                },                      // params
     
    292291                                                decl->location,
    293292                                                "__CFA_receive_wrap_ret",
    294                                                 new EnumInstType( allocationDecl )
     293                                                new EnumInstType( *allocationDecl )
    295294                                        )
    296295                                },
     
    324323                                        decl->location,
    325324                                        "new_req",
    326                                         new StructInstType( requestDecl )
     325                                        new StructInstType( *requestDecl )
    327326                                )
    328327                        ));
     
    332331                        derivedReceive->params.push_back( ast::deepCopy( derivedActorRef ) );
    333332                        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 ) );
    337336
    338337                        // Generates: allocation (*my_work_fn)( derived_actor &, derived_msg &, actor **, message ** ) = receive;
     
    349348                        // Function type is: allocation (*)( actor &, message & )
    350349                        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 ) );
    356355
    357356                        // Generates: allocation (*fn)( actor &, message & ) = (allocation (*)( actor &, message & ))my_work_fn;
     
    379378                                        {
    380379                                                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 ),
    383382                                                new NameExpr( decl->location, "fn" )
    384383                                        }
     
    444443  public:
    445444        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,
    447446                FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls),
    448447                requestDecl(requestDecl), allocationDecl(allocationDecl), actorDecl(actorDecl), msgDecl(msgDecl), forwardDecls(forwardDecls) {}
     
    454453struct FwdDeclOperator : public ast::WithDeclsToAdd {
    455454        unordered_set<const StructDecl *> & actorStructDecls;
    456         unordered_set<const StructDecl *> & messageStructDecls;
     455        unordered_set<const StructDecl *>  & messageStructDecls;
    457456        FwdDeclTable & forwardDecls;
    458457
     
    496495        // for storing through the passes
    497496        // 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;
    502507
    503508        // first pass collects ptrs to allocation enum, request type, and generic receive fn typedef
    504509        // 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 );
    507512
    508513        // 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 )
    510515                return;
    511516
    512517        // second pass locates all receive() routines that overload the generic receive fn
    513518        // 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 );
    516521
    517522        // The third pass forward declares operator '|' send routines
Note: See TracChangeset for help on using the changeset viewer.