Changeset fc1a3e2 for src/Concurrency/Keywords.cpp
- Timestamp:
- Apr 19, 2024, 2:36:52 PM (6 months ago)
- Branches:
- master
- Children:
- ba97ebf
- Parents:
- b9b6efb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cpp
rb9b6efb rfc1a3e2 991 991 ast::CompoundStmt * body = 992 992 new ast::CompoundStmt( stmt->location, { stmt->stmt } ); 993 993 994 994 return addStatements( body, stmt->mutexObjs );; 995 995 } … … 1180 1180 1181 1181 // 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 1183 1183 ast::ExprStmt * MutexKeyword::genVirtLockUnlockExpr( const std::string & fnName, ast::ptr<ast::Expr> expr, const CodeLocation & location, ast::Expr * param ) { 1184 1184 return new ast::ExprStmt( location, … … 1187 1187 ast::UntypedExpr::createDeref( 1188 1188 location, 1189 new ast::CastExpr( location, 1189 new ast::CastExpr( location, 1190 1190 param, 1191 1191 new ast::PointerType( new ast::TypeofType( new ast::UntypedExpr( … … 1208 1208 //adds an if/elif clause for each lock to assign type from void ptr based on ptr address 1209 1209 for ( long unsigned int i = 0; i < args.size(); i++ ) { 1210 1210 1211 1211 ast::UntypedExpr * ifCond = new ast::UntypedExpr( location, 1212 1212 new ast::NameExpr( location, "?==?" ), { … … 1216 1216 ); 1217 1217 1218 ast::IfStmt * currLockIf = new ast::IfStmt( 1218 ast::IfStmt * currLockIf = new ast::IfStmt( 1219 1219 location, 1220 1220 ifCond, 1221 1221 genVirtLockUnlockExpr( fnName, args.at(i), location, ast::deepCopy( thisParam ) ) 1222 1222 ); 1223 1223 1224 1224 if ( i == 0 ) { 1225 1225 outerLockIf = currLockIf; … … 1235 1235 1236 1236 void flattenTuple( const ast::UntypedTupleExpr * tuple, std::vector<ast::ptr<ast::Expr>> & output ) { 1237 1238 1239 1240 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 } 1242 1242 } 1243 1243 … … 1255 1255 // std::string unlockFnName = mutex_func_namer.newName(); 1256 1256 1257 1258 1259 1260 1261 1262 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 } 1264 1264 1265 1265 // Make pointer to the monitors. … … 1302 1302 // adds a nested try stmt for each lock we are locking 1303 1303 for ( long unsigned int i = 0; i < flattenedArgs.size(); i++ ) { 1304 ast::UntypedExpr * innerAccess = new ast::UntypedExpr( 1304 ast::UntypedExpr * innerAccess = new ast::UntypedExpr( 1305 1305 location, 1306 1306 new ast::NameExpr( location,"?[?]" ), { … … 1426 1426 // ); 1427 1427 1428 // ast::IfStmt * currLockIf = new ast::IfStmt( 1428 // ast::IfStmt * currLockIf = new ast::IfStmt( 1429 1429 // location, 1430 1430 // ast::deepCopy( ifCond ), … … 1432 1432 // ); 1433 1433 1434 // ast::IfStmt * currUnlockIf = new ast::IfStmt( 1434 // ast::IfStmt * currUnlockIf = new ast::IfStmt( 1435 1435 // location, 1436 1436 // ifCond, 1437 1437 // genVirtLockUnlockExpr( "unlock", args.at(i), location, ast::deepCopy( thisParam ) ) 1438 1438 // ); 1439 1439 1440 1440 // if ( i == 0 ) { 1441 1441 // outerLockIf = currLockIf; … … 1450 1450 // lastUnlockIf = currUnlockIf; 1451 1451 // } 1452 1452 1453 1453 // // add pointer typing if/elifs to body of routines 1454 1454 // lock_decl->stmts = new ast::CompoundStmt( location, { outerLockIf } );
Note: See TracChangeset
for help on using the changeset viewer.