Changeset f2e40a9f for src/Concurrency/Keywords.cc
- Timestamp:
- Mar 15, 2017, 9:43:15 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 27fed7f1, 738e304
- Parents:
- bf4ac09 (diff), 9b443c7f (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. - git-author:
- Peter A. Buhr <pabuhr@…> (03/15/17 21:25:49)
- git-committer:
- Peter A. Buhr <pabuhr@…> (03/15/17 21:43:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
rbf4ac09 rf2e40a9f 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[] = { a, b};90 // monitor_desc * __monitors[] = { get_monitor(a), get_monitor(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; 100 101 101 102 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); … … 107 108 acceptAll( translationUnit, impl ); 108 109 } 110 111 private: 112 StructDecl* monitor_decl = nullptr; 109 113 }; 110 114 … … 133 137 if( ! body ) return; 134 138 139 assert(monitor_decl); 135 140 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 } 136 148 } 137 149 … … 167 179 168 180 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_decl 194 ) 195 ), 196 new ConstantExpr( Constant::from_ulong( args.size() ) ), 197 false, 198 false 199 ), 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 169 210 //in reverse order : 170 211 // monitor_guard_t __guard = { __monitors, # }; … … 181 222 new ListInit( 182 223 { 183 new SingleInit( new NameExpr( "__monitors") ),224 new SingleInit( new VariableExpr( monitors ) ), 184 225 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 185 226 } … … 189 230 190 231 //monitor_desc * __monitors[] = { a, b }; 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 ); 232 body->push_front( new DeclStmt( noLabels, monitors) ); 217 233 } 218 234 };
Note:
See TracChangeset
for help on using the changeset viewer.