Changes in src/Concurrency/Keywords.cc [be9288a:97e3296]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
rbe9288a r97e3296 200 200 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); 201 201 void validate( DeclarationWithType * ); 202 void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &);202 void addStatments( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &); 203 203 204 204 static void implement( std::list< Declaration * > & translationUnit ) { … … 210 210 StructDecl* monitor_decl = nullptr; 211 211 StructDecl* guard_decl = nullptr; 212 213 static std::unique_ptr< Type > generic_func; 212 214 }; 215 216 std::unique_ptr< Type > MutexKeyword::generic_func = std::unique_ptr< Type >( 217 new FunctionType( 218 noQualifiers, 219 true 220 ) 221 ); 213 222 214 223 //----------------------------------------------------------------------------- … … 394 403 // Mutex keyword implementation 395 404 //============================================================================================= 405 396 406 void MutexKeyword::visit(FunctionDecl* decl) { 397 407 Visitor::visit(decl); … … 410 420 if( !guard_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl ); 411 421 412 addStatments( body, mutexArgs );422 addStatments( decl, body, mutexArgs ); 413 423 } 414 424 … … 456 466 } 457 467 458 void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {468 void MutexKeyword::addStatments( FunctionDecl* func, CompoundStmt * body, const std::list<DeclarationWithType * > & args ) { 459 469 ObjectDecl * monitors = new ObjectDecl( 460 470 "__monitors", … … 487 497 ); 488 498 499 assert(generic_func); 500 489 501 //in reverse order : 490 // monitor_guard_t __guard = { __monitors, # };502 // monitor_guard_t __guard = { __monitors, #, func }; 491 503 body->push_front( 492 504 new DeclStmt( noLabels, new ObjectDecl( … … 502 514 { 503 515 new SingleInit( new VariableExpr( monitors ) ), 504 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 516 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ), 517 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) ) 505 518 }, 506 519 noDesignators,
Note: See TracChangeset
for help on using the changeset viewer.