Changes in src/Concurrency/Keywords.cc [9243cc91:64adb03]
- File:
-
- 1 edited
-
src/Concurrency/Keywords.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
r9243cc91 r64adb03 88 88 //Handles mutex routines definitions : 89 89 // void foo( A * mutex a, B * mutex b, int i ) { void foo( A * a, B * b, int i ) { 90 // monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b)};90 // monitor_desc * __monitors[] = { a, b }; 91 91 // monitor_guard_t __guard = { __monitors, 2 }; 92 92 // /*Some code*/ => /*Some code*/ … … 98 98 using Visitor::visit; 99 99 virtual void visit( FunctionDecl *functionDecl ) override final; 100 virtual void visit( StructDecl *functionDecl ) override final;101 100 102 101 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); … … 108 107 acceptAll( translationUnit, impl ); 109 108 } 110 111 private:112 StructDecl* monitor_decl = nullptr;113 109 }; 114 110 … … 137 133 if( ! body ) return; 138 134 139 assert(monitor_decl);140 135 addStatments( body, mutexArgs ); 141 }142 143 void MutexKeyword::visit(StructDecl* decl) {144 if( decl->get_name() == "monitor_desc" ) {145 assert( !monitor_decl );146 monitor_decl = decl;147 }148 136 } 149 137 … … 179 167 180 168 void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) { 181 182 ObjectDecl * monitors = new ObjectDecl(183 "__monitors",184 noStorage,185 LinkageSpec::Cforall,186 nullptr,187 new ArrayType(188 noQualifiers,189 new PointerType(190 noQualifiers,191 new StructInstType(192 noQualifiers,193 monitor_decl194 )195 ),196 new ConstantExpr( Constant::from_ulong( args.size() ) ),197 false,198 false199 ),200 new ListInit(201 map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){202 return new SingleInit( new UntypedExpr(203 new NameExpr( "get_monitor" ),204 { new VariableExpr( var ) }205 ) );206 })207 )208 );209 210 169 //in reverse order : 211 170 // monitor_guard_t __guard = { __monitors, # }; … … 222 181 new ListInit( 223 182 { 224 new SingleInit( new VariableExpr( monitors) ),183 new SingleInit( new NameExpr( "__monitors" ) ), 225 184 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 226 185 } … … 230 189 231 190 //monitor_desc * __monitors[] = { a, b }; 232 body->push_front( new DeclStmt( noLabels, monitors) ); 191 body->push_front( 192 new DeclStmt( noLabels, new ObjectDecl( 193 "__monitors", 194 noStorage, 195 LinkageSpec::Cforall, 196 nullptr, 197 new ArrayType( 198 noQualifiers, 199 new PointerType( 200 noQualifiers, 201 new StructInstType( 202 noQualifiers, 203 "monitor_desc" 204 ) 205 ), 206 new ConstantExpr( Constant::from_ulong( args.size() ) ), 207 false, 208 false 209 ), 210 new ListInit( 211 map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){ 212 return new SingleInit( new VariableExpr( var ) ); 213 }) 214 ) 215 )) 216 ); 233 217 } 234 218 };
Note:
See TracChangeset
for help on using the changeset viewer.