Ignore:
Timestamp:
Aug 31, 2023, 11:31:15 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
950c58e
Parents:
92355883 (diff), 686912c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/KeywordsNew.cpp

    r92355883 r2a301ff  
    534534void ConcurrentSueKeyword::addGetRoutines(
    535535                const ast::ObjectDecl * field, const ast::FunctionDecl * forward ) {
     536        // Clone the signature and then build the body.
     537        ast::FunctionDecl * decl = ast::deepCopy( forward );
     538
    536539        // Say it is generated at the "same" places as the forward declaration.
    537         const CodeLocation & location = forward->location;
    538 
    539         const ast::DeclWithType * param = forward->params.front();
     540        const CodeLocation & location = decl->location;
     541
     542        const ast::DeclWithType * param = decl->params.front();
    540543        ast::Stmt * stmt = new ast::ReturnStmt( location,
    541544                new ast::AddressExpr( location,
     
    551554        );
    552555
    553         ast::FunctionDecl * decl = ast::deepCopy( forward );
    554556        decl->stmts = new ast::CompoundStmt( location, { stmt } );
    555557        declsToAddAfter.push_back( decl );
     
    12361238}
    12371239
     1240void flattenTuple( const ast::UntypedTupleExpr * tuple, std::vector<ast::ptr<ast::Expr>> & output ) {
     1241    for ( auto & expr : tuple->exprs ) {
     1242        const ast::UntypedTupleExpr * innerTuple = dynamic_cast<const ast::UntypedTupleExpr *>(expr.get());
     1243        if ( innerTuple ) flattenTuple( innerTuple, output );
     1244        else output.emplace_back( ast::deepCopy( expr ));
     1245    }
     1246}
     1247
    12381248ast::CompoundStmt * MutexKeyword::addStatements(
    12391249                const ast::CompoundStmt * body,
     
    12481258        // std::string lockFnName = mutex_func_namer.newName();
    12491259        // std::string unlockFnName = mutex_func_namer.newName();
     1260
     1261    // If any arguments to the mutex stmt are tuples, flatten them
     1262    std::vector<ast::ptr<ast::Expr>> flattenedArgs;
     1263    for ( auto & arg : args ) {
     1264        const ast::UntypedTupleExpr * tuple = dynamic_cast<const ast::UntypedTupleExpr *>(args.at(0).get());
     1265        if ( tuple ) flattenTuple( tuple, flattenedArgs );
     1266        else flattenedArgs.emplace_back( ast::deepCopy( arg ));
     1267    }
    12501268
    12511269        // Make pointer to the monitors.
     
    12571275                                new ast::VoidType()
    12581276                        ),
    1259                         ast::ConstantExpr::from_ulong( location, args.size() ),
     1277                        ast::ConstantExpr::from_ulong( location, flattenedArgs.size() ),
    12601278                        ast::FixedLen,
    12611279                        ast::DynamicDim
     
    12641282                        location,
    12651283                        map_range<std::vector<ast::ptr<ast::Init>>>(
    1266                                 args, [](const ast::Expr * expr) {
     1284                                flattenedArgs, [](const ast::Expr * expr) {
    12671285                                        return new ast::SingleInit(
    12681286                                                expr->location,
     
    12871305
    12881306        // adds a nested try stmt for each lock we are locking
    1289         for ( long unsigned int i = 0; i < args.size(); i++ ) {
     1307        for ( long unsigned int i = 0; i < flattenedArgs.size(); i++ ) {
    12901308                ast::UntypedExpr * innerAccess = new ast::UntypedExpr(
    12911309                        location,
     
    12981316                // make the try body
    12991317                ast::CompoundStmt * currTryBody = new ast::CompoundStmt( location );
    1300                 ast::IfStmt * lockCall = genTypeDiscrimLockUnlock( "lock", args, location, innerAccess );
     1318                ast::IfStmt * lockCall = genTypeDiscrimLockUnlock( "lock", flattenedArgs, location, innerAccess );
    13011319                currTryBody->push_back( lockCall );
    13021320
    13031321                // make the finally stmt
    13041322                ast::CompoundStmt * currFinallyBody = new ast::CompoundStmt( location );
    1305                 ast::IfStmt * unlockCall = genTypeDiscrimLockUnlock( "unlock", args, location, innerAccess );
     1323                ast::IfStmt * unlockCall = genTypeDiscrimLockUnlock( "unlock", flattenedArgs, location, innerAccess );
    13061324                currFinallyBody->push_back( unlockCall );
    13071325
     
    13431361                                                new ast::SingleInit(
    13441362                                                        location,
    1345                                                         ast::ConstantExpr::from_ulong( location, args.size() ) ),
     1363                                                        ast::ConstantExpr::from_ulong( location, flattenedArgs.size() ) ),
    13461364                                        },
    13471365                                        {},
Note: See TracChangeset for help on using the changeset viewer.