Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    r6cebfef re84ab3d  
    302302                void postvisit( FunctionDecl * decl );
    303303                void postvisit(   StructDecl * decl );
    304                 Statement * postmutate( MutexStmt * stmt );
    305304
    306305                std::list<DeclarationWithType*> findMutexArgs( FunctionDecl*, bool & first );
     
    308307                void addDtorStatements( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &);
    309308                void addStatements( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &);
    310                 void addStatements( CompoundStmt * body, const std::list<Expression * > & args );
    311309                void addThreadDtorStatements( FunctionDecl* func, CompoundStmt * body, const std::list<DeclarationWithType * > & args );
    312310
     
    314312                        PassVisitor< MutexKeyword > impl;
    315313                        acceptAll( translationUnit, impl );
    316                         mutateAll( translationUnit, impl );
    317314                }
    318315
     
    938935                        thread_guard_decl = decl;
    939936                }
    940         }
    941 
    942         Statement * MutexKeyword::postmutate( MutexStmt * stmt ) {
    943                 std::list<Statement *> stmtsForCtor;
    944                 stmtsForCtor.push_back(stmt->stmt);
    945                 CompoundStmt * body = new CompoundStmt( stmtsForCtor );
    946                 addStatements( body, stmt->mutexObjs);
    947                 return body;
    948937        }
    949938
     
    10691058                        ))
    10701059                );
    1071         }
    1072 
    1073         void MutexKeyword::addStatements( CompoundStmt * body, const std::list<Expression * > & args ) {
    1074                 ObjectDecl * monitors = new ObjectDecl(
    1075                         "__monitors",
    1076                         noStorageClasses,
    1077                         LinkageSpec::Cforall,
    1078                         nullptr,
    1079                         new ArrayType(
    1080                                 noQualifiers,
    1081                                 new PointerType(
    1082                                         noQualifiers,
    1083                                         new StructInstType(
    1084                                                 noQualifiers,
    1085                                                 monitor_decl
    1086                                         )
    1087                                 ),
    1088                                 new ConstantExpr( Constant::from_ulong( args.size() ) ),
    1089                                 false,
    1090                                 false
    1091                         ),
    1092                         new ListInit(
    1093                                 map_range < std::list<Initializer*> > ( args, [](Expression * var ){
    1094                                         return new SingleInit( new UntypedExpr(
    1095                                                 new NameExpr( "get_monitor" ),
    1096                                                 { var }
    1097                                         ) );
    1098                                 })
    1099                         )
    1100                 );
    1101 
    1102                 // in reverse order :
    1103                 // monitor_guard_t __guard = { __monitors, # };
    1104                 body->push_front(
    1105                         new DeclStmt( new ObjectDecl(
    1106                                 "__guard",
    1107                                 noStorageClasses,
    1108                                 LinkageSpec::Cforall,
    1109                                 nullptr,
    1110                                 new StructInstType(
    1111                                         noQualifiers,
    1112                                         guard_decl
    1113                                 ),
    1114                                 new ListInit(
    1115                                         {
    1116                                                 new SingleInit( new VariableExpr( monitors ) ),
    1117                                                 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) )
    1118                                         },
    1119                                         noDesignators,
    1120                                         true
    1121                                 )
    1122                         ))
    1123                 );
    1124 
    1125                 //monitor$ * __monitors[] = { get_monitor(a), get_monitor(b) };
    1126                 body->push_front( new DeclStmt( monitors) );
    11271060        }
    11281061
Note: See TracChangeset for help on using the changeset viewer.