Ignore:
Timestamp:
Apr 19, 2024, 2:36:52 PM (6 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
ba97ebf
Parents:
b9b6efb
Message:

Style update. Focused on indentation and trailing whitespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cpp

    rb9b6efb rfc1a3e2  
    991991        ast::CompoundStmt * body =
    992992                        new ast::CompoundStmt( stmt->location, { stmt->stmt } );
    993        
     993
    994994        return addStatements( body, stmt->mutexObjs );;
    995995}
     
    11801180
    11811181// generates a cast to the void ptr to the appropriate lock type and dereferences it before calling lock or unlock on it
    1182 // used to undo the type erasure done by storing all the lock pointers as void 
     1182// used to undo the type erasure done by storing all the lock pointers as void
    11831183ast::ExprStmt * MutexKeyword::genVirtLockUnlockExpr( const std::string & fnName, ast::ptr<ast::Expr> expr, const CodeLocation & location, ast::Expr * param ) {
    11841184        return new ast::ExprStmt( location,
     
    11871187                                ast::UntypedExpr::createDeref(
    11881188                                        location,
    1189                                         new ast::CastExpr( location, 
     1189                                        new ast::CastExpr( location,
    11901190                                                param,
    11911191                                                new ast::PointerType( new ast::TypeofType( new ast::UntypedExpr(
     
    12081208        //adds an if/elif clause for each lock to assign type from void ptr based on ptr address
    12091209        for ( long unsigned int i = 0; i < args.size(); i++ ) {
    1210                
     1210
    12111211                ast::UntypedExpr * ifCond = new ast::UntypedExpr( location,
    12121212                        new ast::NameExpr( location, "?==?" ), {
     
    12161216                );
    12171217
    1218                 ast::IfStmt * currLockIf = new ast::IfStmt( 
     1218                ast::IfStmt * currLockIf = new ast::IfStmt(
    12191219                        location,
    12201220                        ifCond,
    12211221                        genVirtLockUnlockExpr( fnName, args.at(i), location, ast::deepCopy( thisParam ) )
    12221222                );
    1223                
     1223
    12241224                if ( i == 0 ) {
    12251225                        outerLockIf = currLockIf;
     
    12351235
    12361236void flattenTuple( const ast::UntypedTupleExpr * tuple, std::vector<ast::ptr<ast::Expr>> & output ) {
    1237     for ( auto & expr : tuple->exprs ) {
    1238         const ast::UntypedTupleExpr * innerTuple = dynamic_cast<const ast::UntypedTupleExpr *>(expr.get());
    1239         if ( innerTuple ) flattenTuple( innerTuple, output );
    1240         else output.emplace_back( ast::deepCopy( expr ));
    1241     }
     1237        for ( auto & expr : tuple->exprs ) {
     1238                const ast::UntypedTupleExpr * innerTuple = dynamic_cast<const ast::UntypedTupleExpr *>(expr.get());
     1239                if ( innerTuple ) flattenTuple( innerTuple, output );
     1240                else output.emplace_back( ast::deepCopy( expr ));
     1241        }
    12421242}
    12431243
     
    12551255        // std::string unlockFnName = mutex_func_namer.newName();
    12561256
    1257     // If any arguments to the mutex stmt are tuples, flatten them
    1258     std::vector<ast::ptr<ast::Expr>> flattenedArgs;
    1259     for ( auto & arg : args ) {
    1260         const ast::UntypedTupleExpr * tuple = dynamic_cast<const ast::UntypedTupleExpr *>(args.at(0).get());
    1261         if ( tuple ) flattenTuple( tuple, flattenedArgs );
    1262         else flattenedArgs.emplace_back( ast::deepCopy( arg ));
    1263     }
     1257        // If any arguments to the mutex stmt are tuples, flatten them
     1258        std::vector<ast::ptr<ast::Expr>> flattenedArgs;
     1259        for ( auto & arg : args ) {
     1260                const ast::UntypedTupleExpr * tuple = dynamic_cast<const ast::UntypedTupleExpr *>(args.at(0).get());
     1261                if ( tuple ) flattenTuple( tuple, flattenedArgs );
     1262                else flattenedArgs.emplace_back( ast::deepCopy( arg ));
     1263        }
    12641264
    12651265        // Make pointer to the monitors.
     
    13021302        // adds a nested try stmt for each lock we are locking
    13031303        for ( long unsigned int i = 0; i < flattenedArgs.size(); i++ ) {
    1304                 ast::UntypedExpr * innerAccess = new ast::UntypedExpr( 
     1304                ast::UntypedExpr * innerAccess = new ast::UntypedExpr(
    13051305                        location,
    13061306                        new ast::NameExpr( location,"?[?]" ), {
     
    14261426        //      );
    14271427
    1428         //      ast::IfStmt * currLockIf = new ast::IfStmt( 
     1428        //      ast::IfStmt * currLockIf = new ast::IfStmt(
    14291429        //              location,
    14301430        //              ast::deepCopy( ifCond ),
     
    14321432        //      );
    14331433
    1434         //      ast::IfStmt * currUnlockIf = new ast::IfStmt( 
     1434        //      ast::IfStmt * currUnlockIf = new ast::IfStmt(
    14351435        //              location,
    14361436        //              ifCond,
    14371437        //              genVirtLockUnlockExpr( "unlock", args.at(i), location, ast::deepCopy( thisParam ) )
    14381438        //      );
    1439                
     1439
    14401440        //      if ( i == 0 ) {
    14411441        //              outerLockIf = currLockIf;
     
    14501450        //      lastUnlockIf = currUnlockIf;
    14511451        // }
    1452        
     1452
    14531453        // // add pointer typing if/elifs to body of routines
    14541454        // lock_decl->stmts = new ast::CompoundStmt( location, { outerLockIf } );
Note: See TracChangeset for help on using the changeset viewer.