Changeset 2a301ff for src/Concurrency/KeywordsNew.cpp
- Timestamp:
- Aug 31, 2023, 11:31:15 PM (2 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/KeywordsNew.cpp
r92355883 r2a301ff 534 534 void ConcurrentSueKeyword::addGetRoutines( 535 535 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 536 539 // 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(); 540 543 ast::Stmt * stmt = new ast::ReturnStmt( location, 541 544 new ast::AddressExpr( location, … … 551 554 ); 552 555 553 ast::FunctionDecl * decl = ast::deepCopy( forward );554 556 decl->stmts = new ast::CompoundStmt( location, { stmt } ); 555 557 declsToAddAfter.push_back( decl ); … … 1236 1238 } 1237 1239 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 1238 1248 ast::CompoundStmt * MutexKeyword::addStatements( 1239 1249 const ast::CompoundStmt * body, … … 1248 1258 // std::string lockFnName = mutex_func_namer.newName(); 1249 1259 // 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 } 1250 1268 1251 1269 // Make pointer to the monitors. … … 1257 1275 new ast::VoidType() 1258 1276 ), 1259 ast::ConstantExpr::from_ulong( location, args.size() ),1277 ast::ConstantExpr::from_ulong( location, flattenedArgs.size() ), 1260 1278 ast::FixedLen, 1261 1279 ast::DynamicDim … … 1264 1282 location, 1265 1283 map_range<std::vector<ast::ptr<ast::Init>>>( 1266 args, [](const ast::Expr * expr) {1284 flattenedArgs, [](const ast::Expr * expr) { 1267 1285 return new ast::SingleInit( 1268 1286 expr->location, … … 1287 1305 1288 1306 // 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++ ) { 1290 1308 ast::UntypedExpr * innerAccess = new ast::UntypedExpr( 1291 1309 location, … … 1298 1316 // make the try body 1299 1317 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 ); 1301 1319 currTryBody->push_back( lockCall ); 1302 1320 1303 1321 // make the finally stmt 1304 1322 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 ); 1306 1324 currFinallyBody->push_back( unlockCall ); 1307 1325 … … 1343 1361 new ast::SingleInit( 1344 1362 location, 1345 ast::ConstantExpr::from_ulong( location, args.size() ) ),1363 ast::ConstantExpr::from_ulong( location, flattenedArgs.size() ) ), 1346 1364 }, 1347 1365 {},
Note:
See TracChangeset
for help on using the changeset viewer.