Changeset ded018f


Ignore:
Timestamp:
Jul 7, 2023, 9:55:34 AM (11 months ago)
Author:
caparsons <caparson@…>
Branches:
master
Children:
555c599
Parents:
bef2245
Message:

refactored to fix bug in channel_close test. As a consquence can no longer break out of waituntil statements that have an and

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Waituntil.cpp

    rbef2245 rded018f  
    884884                )
    885885            );
    886         else // we reuse the when_cond bools later during unregister so init to false if initially unused
    887             body->push_back(
    888                 new DeclStmt( cLoc,
    889                     new ObjectDecl( cLoc,
    890                         currClause->whenName,
    891                         new BasicType( BasicType::Kind::Bool ),
    892                         new SingleInit( cLoc, ConstantExpr::from_bool( cLoc, false ) )
    893                     )
    894                 )
    895             );
    896886       
    897887        // select_node clause1;
     
    13061296    CompoundStmt * unregisters = new CompoundStmt( loc );
    13071297
    1308     // Collection of optional statement executions following finally clause
    1309     // for each clause:
    1310     // if ( when_cond_i ) clausei->stmt;
    1311     // when_cond_i is repurposed in the finally to store if any statements need to be run after unregisters
    1312     // the statements need to be run outside a finally clause since they may contain non-local transfers
    1313     CompoundStmt * unregisterStmts = new CompoundStmt( loc );
    1314 
    1315     UntypedExpr * statusExpr; // !__CFA_has_clause_run( clause_statuses[i] )
    1316     ExprStmt * assignStmt; // when_cond_i = (!__CFA_has_clause_run( clause_statuses[i] )) && unregister_select( ... , clausei );
     1298
     1299    Expr * statusExpr; // !__CFA_has_clause_run( clause_statuses[i] )
    13171300    for ( int i = 0; i < numClauses; i++ ) {
    13181301        const CodeLocation & cLoc = stmt->clauses.at(i)->location;
     
    13321315       
    13331316        // Generates:
    1334         // when_cond_i = (!__CFA_has_clause_run( clause_statuses[i] )) && unregister_select( ... , clausei );
    1335         assignStmt = new ExprStmt( cLoc,
    1336             UntypedExpr::createAssign( cLoc,
    1337                 new NameExpr( cLoc, clauseData.at(i)->whenName ),
    1338                 new LogicalExpr( cLoc,
    1339                     new CastExpr( cLoc,
    1340                         statusExpr,
    1341                         new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    1342                     ),
    1343                     new CastExpr( cLoc,
    1344                         genSelectTraitCall( stmt->clauses.at(i), clauseData.at(i), "unregister_select" ),
    1345                         new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    1346                     ),
    1347                     LogicalFlag::AndExpr
    1348                 )
    1349             )
    1350         );
    1351 
    1352         if ( stmt->clauses.at(i)->when_cond ) // if ( when_cond_i ) assignStmt
    1353             unregisters->push_back(
    1354                 new IfStmt( cLoc,
    1355                     new NameExpr( cLoc, clauseData.at(i)->whenName ),
    1356                     new CompoundStmt( cLoc, { assignStmt } )
    1357                 )
     1317        // (!__CFA_has_clause_run( clause_statuses[i] )) && unregister_select( ... , clausei );
     1318        statusExpr = new LogicalExpr( cLoc,
     1319            new CastExpr( cLoc,
     1320                statusExpr,
     1321                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
     1322            ),
     1323            new CastExpr( cLoc,
     1324                genSelectTraitCall( stmt->clauses.at(i), clauseData.at(i), "unregister_select" ),
     1325                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
     1326            ),
     1327            LogicalFlag::AndExpr
     1328        );
     1329       
     1330        // if when cond defined generates:
     1331        // when_cond_i && (!__CFA_has_clause_run( clause_statuses[i] )) && unregister_select( ... , clausei );
     1332        if ( stmt->clauses.at(i)->when_cond )
     1333            statusExpr = new LogicalExpr( cLoc,
     1334                new CastExpr( cLoc,
     1335                    new NameExpr( cLoc, clauseData.at(i)->whenName ),
     1336                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
     1337                ),
     1338                new CastExpr( cLoc,
     1339                    statusExpr,
     1340                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
     1341                ),
     1342                LogicalFlag::AndExpr
    13581343            );
    1359         else
    1360             unregisters->push_back( assignStmt );
    1361 
    1362         unregisterStmts->push_back(
     1344
     1345        // generates:
     1346        // if ( statusExpr ) { ... clausei stmt ... }
     1347        unregisters->push_back(
    13631348            new IfStmt( cLoc,
    1364                 new NameExpr( cLoc, clauseData.at(i)->whenName ),
     1349                statusExpr,
    13651350                genStmtBlock( stmt->clauses.at(i), clauseData.at(i) )
    13661351            )
     
    13761361        )
    13771362    );
    1378 
    1379     body->push_back( unregisterStmts );
    1380    
    13811363
    13821364    for ( ClauseData * datum : clauseData )
Note: See TracChangeset for help on using the changeset viewer.