Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Concurrency/Waituntil.cpp

    rded018f red1a7ab8  
    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            );
    886896       
    887897        // select_node clause1;
     
    12961306    CompoundStmt * unregisters = new CompoundStmt( loc );
    12971307
    1298 
    1299     Expr * statusExpr; // !__CFA_has_clause_run( clause_statuses[i] )
     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 );
    13001317    for ( int i = 0; i < numClauses; i++ ) {
    13011318        const CodeLocation & cLoc = stmt->clauses.at(i)->location;
     
    13151332       
    13161333        // Generates:
    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
     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                )
    13431358            );
    1344 
    1345         // generates:
    1346         // if ( statusExpr ) { ... clausei stmt ... }
    1347         unregisters->push_back(
     1359        else
     1360            unregisters->push_back( assignStmt );
     1361
     1362        unregisterStmts->push_back(
    13481363            new IfStmt( cLoc,
    1349                 statusExpr,
     1364                new NameExpr( cLoc, clauseData.at(i)->whenName ),
    13501365                genStmtBlock( stmt->clauses.at(i), clauseData.at(i) )
    13511366            )
     
    13611376        )
    13621377    );
     1378
     1379    body->push_back( unregisterStmts );
     1380   
    13631381
    13641382    for ( ClauseData * datum : clauseData )
Note: See TracChangeset for help on using the changeset viewer.