Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/KeywordsNew.cpp

    rb2ecd48 r835d6e8  
    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 
    539536        // Say it is generated at the "same" places as the forward declaration.
    540         const CodeLocation & location = decl->location;
    541 
    542         const ast::DeclWithType * param = decl->params.front();
     537        const CodeLocation & location = forward->location;
     538
     539        const ast::DeclWithType * param = forward->params.front();
    543540        ast::Stmt * stmt = new ast::ReturnStmt( location,
    544541                new ast::AddressExpr( location,
     
    554551        );
    555552
     553        ast::FunctionDecl * decl = ast::deepCopy( forward );
    556554        decl->stmts = new ast::CompoundStmt( location, { stmt } );
    557555        declsToAddAfter.push_back( decl );
     
    12381236}
    12391237
    1240 void 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 
    12481238ast::CompoundStmt * MutexKeyword::addStatements(
    12491239                const ast::CompoundStmt * body,
     
    12581248        // std::string lockFnName = mutex_func_namer.newName();
    12591249        // 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     }
    12681250
    12691251        // Make pointer to the monitors.
     
    12751257                                new ast::VoidType()
    12761258                        ),
    1277                         ast::ConstantExpr::from_ulong( location, flattenedArgs.size() ),
     1259                        ast::ConstantExpr::from_ulong( location, args.size() ),
    12781260                        ast::FixedLen,
    12791261                        ast::DynamicDim
     
    12821264                        location,
    12831265                        map_range<std::vector<ast::ptr<ast::Init>>>(
    1284                                 flattenedArgs, [](const ast::Expr * expr) {
     1266                                args, [](const ast::Expr * expr) {
    12851267                                        return new ast::SingleInit(
    12861268                                                expr->location,
     
    13051287
    13061288        // adds a nested try stmt for each lock we are locking
    1307         for ( long unsigned int i = 0; i < flattenedArgs.size(); i++ ) {
     1289        for ( long unsigned int i = 0; i < args.size(); i++ ) {
    13081290                ast::UntypedExpr * innerAccess = new ast::UntypedExpr(
    13091291                        location,
     
    13161298                // make the try body
    13171299                ast::CompoundStmt * currTryBody = new ast::CompoundStmt( location );
    1318                 ast::IfStmt * lockCall = genTypeDiscrimLockUnlock( "lock", flattenedArgs, location, innerAccess );
     1300                ast::IfStmt * lockCall = genTypeDiscrimLockUnlock( "lock", args, location, innerAccess );
    13191301                currTryBody->push_back( lockCall );
    13201302
    13211303                // make the finally stmt
    13221304                ast::CompoundStmt * currFinallyBody = new ast::CompoundStmt( location );
    1323                 ast::IfStmt * unlockCall = genTypeDiscrimLockUnlock( "unlock", flattenedArgs, location, innerAccess );
     1305                ast::IfStmt * unlockCall = genTypeDiscrimLockUnlock( "unlock", args, location, innerAccess );
    13241306                currFinallyBody->push_back( unlockCall );
    13251307
     
    13611343                                                new ast::SingleInit(
    13621344                                                        location,
    1363                                                         ast::ConstantExpr::from_ulong( location, flattenedArgs.size() ) ),
     1345                                                        ast::ConstantExpr::from_ulong( location, args.size() ) ),
    13641346                                        },
    13651347                                        {},
Note: See TracChangeset for help on using the changeset viewer.