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