Changeset 135b431


Ignore:
Timestamp:
Aug 25, 2017, 11:09:02 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
6b224a5
Parents:
3eab0ef6
Message:

First step for waitfor statments, does nothing but is there

Location:
src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r3eab0ef6 r135b431  
    414414Statement * build_compound( StatementNode * first );
    415415Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
     416WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when );
     417WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing );
     418WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when );
     419WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when );
    416420
    417421//##############################################################################
  • src/Parser/StatementNode.cc

    r3eab0ef6 r135b431  
    9393                elseb = branches.front();
    9494        } // if
    95        
     95
    9696        std::list< Statement * > init;
    9797        if ( ctl->init != 0 ) {
     
    207207}
    208208
     209WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when ) {
     210        auto node = new WaitForStmt();
     211
     212        WaitForStmt::Target target;
     213        target.function = maybeBuild<Expression>( targetExpr );
     214        buildMoveList< Expression >( targetExpr, target.arguments );
     215        delete targetExpr;
     216
     217        node->clauses.push_back( WaitForStmt::Clause{
     218                target,
     219                maybeMoveBuild<Statement >( stmt ),
     220                maybeMoveBuild<Expression>( when )
     221        });
     222
     223        return node;
     224}
     225
     226WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) {
     227        WaitForStmt::Target target;
     228
     229        target.function = maybeBuild<Expression>( targetExpr );
     230        buildMoveList< Expression >( targetExpr, target.arguments );
     231        delete targetExpr;
     232
     233        node->clauses.push_back( WaitForStmt::Clause{
     234                std::move( target ),
     235                maybeMoveBuild<Statement >( stmt ),
     236                maybeMoveBuild<Expression>( when )
     237        });
     238
     239        return node;
     240}
     241
     242WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when ) {
     243        auto node = new WaitForStmt();
     244
     245        if( timeout ) {
     246                node->timeout.time      = maybeMoveBuild<Expression>( timeout );
     247                node->timeout.statement = maybeMoveBuild<Statement >( stmt    );
     248                node->timeout.condition = maybeMoveBuild<Expression>( when    );
     249        }
     250        else {
     251                node->orelse.statement  = maybeMoveBuild<Statement >( stmt    );
     252                node->orelse.condition  = maybeMoveBuild<Expression>( when    );
     253        }
     254
     255        return node;
     256}
     257
     258WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when,  StatementNode * else_stmt, ExpressionNode * else_when ) {
     259        auto node = new WaitForStmt();
     260
     261        node->timeout.time      = maybeMoveBuild<Expression>( timeout );
     262        node->timeout.statement = maybeMoveBuild<Statement >( stmt    );
     263        node->timeout.condition = maybeMoveBuild<Expression>( when    );
     264
     265        node->orelse.statement = maybeMoveBuild<Statement >( else_stmt );
     266        node->orelse.condition = maybeMoveBuild<Expression>( else_when );
     267
     268        return node;
     269}
     270
     271// WaitForStmt::Target build_waitfor( const std::string * name, ExpressionNode * arguments ) {
     272//       return WaitForStmt::Clause{
     273
     274//       };
     275// }
     276
    209277Statement *build_compound( StatementNode *first ) {
    210278        CompoundStmt *cs = new CompoundStmt( noLabels );
  • src/Parser/parser.yy

    r3eab0ef6 r135b431  
    9797        DeclarationNode::TypeClass tclass;
    9898        StatementNode * sn;
     99        WaitForStmt * wfs;
    99100        ConstantExpr * constant;
    100101        IfCtl * ifctl;
     
    187188%type<flag> asm_volatile_opt
    188189%type<en> handler_predicate_opt
     190%type<en> when_clause_opt timeout
    189191
    190192// statements
     
    192194%type<sn> iteration_statement                   jump_statement
    193195%type<sn> with_statement                                exception_statement                     asm_statement
    194 %type<sn> when_clause_opt                               waitfor_statement                       waitfor_clause                          waitfor                         timeout
     196%type<sn> waitfor_statement
    195197%type<sn> fall_through_opt                              fall_through
    196198%type<sn> statement                                             statement_list
     
    202204%type<sn> handler_clause                                finally_clause
    203205%type<catch_kind> handler_key
     206%type<wfs> waitfor_clause
     207%type<en> waitfor
    204208
    205209// declarations
     
    979983when_clause_opt:
    980984        // empty
    981                 { $$ = nullptr; }                                                               // FIX ME
     985                { $$ = nullptr; }
    982986        | WHEN '(' comma_expression ')'
    983                 { $$ = nullptr; }                                                               // FIX ME
     987                { $$ = $3; }
    984988        ;
    985989
    986990waitfor:
    987991        WAITFOR '(' identifier ')'
    988                 { $$ = nullptr; }                                                               // FIX ME
     992                {
     993                        $$ = new ExpressionNode( new NameExpr( *$3 ) );
     994                        delete $3;
     995                }
    989996        | WAITFOR '(' identifier ',' argument_expression_list ')'
    990                 { $$ = nullptr; }                                                               // FIX ME
     997                {
     998                        $$ = new ExpressionNode( new NameExpr( *$3 ) );
     999                        $$->set_last( $5 );
     1000                        delete $3;
     1001                }
    9911002        ;
    9921003
    9931004timeout:
    9941005        TIMEOUT '(' comma_expression ')'
    995                 { $$ = nullptr; }                                                               // FIX ME
     1006                { $$ = $3; }
    9961007        ;
    9971008
    9981009waitfor_clause:
    9991010        when_clause_opt waitfor statement %prec THEN
    1000                 { $$ = nullptr; }                                                               // FIX ME
     1011                { $$ = build_waitfor( $2, $3, $1 ); }
    10011012        | when_clause_opt waitfor statement WOR waitfor_clause
    1002                 { $$ = nullptr; }                                                               // FIX ME
     1013                { $$ = build_waitfor( $2, $3, $1, $5 ); }
    10031014        | when_clause_opt timeout statement %prec THEN
    1004                 { $$ = nullptr; }                                                               // FIX ME
     1015                { $$ = build_waitfor_timeout( $2, $3, $1 ); }
    10051016        | when_clause_opt ELSE statement
    1006                 { $$ = nullptr; }                                                               // FIX ME
     1017                { $$ = build_waitfor_timeout( nullptr, $3, $1 ); }
    10071018        | when_clause_opt timeout statement WOR when_clause_opt ELSE statement
    1008                 { $$ = nullptr; }                                                               // FIX ME
     1019                { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); }
    10091020        ;
    10101021
    10111022waitfor_statement:
    10121023        when_clause_opt waitfor statement %prec THEN
    1013                 { $$ = nullptr; }                                                               // FIX ME
     1024                { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); }
    10141025        | when_clause_opt waitfor statement WOR waitfor_clause
    1015                 { $$ = nullptr; }                                                               // FIX ME
     1026                { $$ = new StatementNode( build_waitfor( $2, $3, $1, $5 ) ); }
    10161027        ;
    10171028
  • src/SynTree/Mutator.cc

    r3eab0ef6 r135b431  
    3232Mutator::~Mutator() {}
    3333
    34 DeclarationWithType *Mutator::mutate( ObjectDecl *objectDecl ) {
     34DeclarationWithType * Mutator::mutate( ObjectDecl *objectDecl ) {
    3535        objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) );
    3636        objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) );
     
    3939}
    4040
    41 DeclarationWithType *Mutator::mutate( FunctionDecl *functionDecl ) {
     41DeclarationWithType * Mutator::mutate( FunctionDecl *functionDecl ) {
    4242        functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
    4343        functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
     
    4545}
    4646
    47 Declaration *Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
     47Declaration * Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
    4848        mutateAll( aggregateDecl->get_parameters(), *this );
    4949        mutateAll( aggregateDecl->get_members(), *this );
     
    5151}
    5252
    53 Declaration *Mutator::mutate( StructDecl *aggregateDecl ) {
     53Declaration * Mutator::mutate( StructDecl *aggregateDecl ) {
    5454        handleAggregateDecl( aggregateDecl );
    5555        return aggregateDecl;
    5656}
    5757
    58 Declaration *Mutator::mutate( UnionDecl *aggregateDecl ) {
     58Declaration * Mutator::mutate( UnionDecl *aggregateDecl ) {
    5959        handleAggregateDecl( aggregateDecl );
    6060        return aggregateDecl;
    6161}
    6262
    63 Declaration *Mutator::mutate( EnumDecl *aggregateDecl ) {
     63Declaration * Mutator::mutate( EnumDecl *aggregateDecl ) {
    6464        handleAggregateDecl( aggregateDecl );
    6565        return aggregateDecl;
    6666}
    6767
    68 Declaration *Mutator::mutate( TraitDecl *aggregateDecl ) {
     68Declaration * Mutator::mutate( TraitDecl *aggregateDecl ) {
    6969        handleAggregateDecl( aggregateDecl );
    7070        return aggregateDecl;
    7171}
    7272
    73 Declaration *Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
     73Declaration * Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
    7474        mutateAll( typeDecl->get_parameters(), *this );
    7575        mutateAll( typeDecl->get_assertions(), *this );
     
    7878}
    7979
    80 TypeDecl *Mutator::mutate( TypeDecl *typeDecl ) {
     80TypeDecl * Mutator::mutate( TypeDecl *typeDecl ) {
    8181        handleNamedTypeDecl( typeDecl );
    8282        typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) );
     
    8484}
    8585
    86 Declaration *Mutator::mutate( TypedefDecl *typeDecl ) {
     86Declaration * Mutator::mutate( TypedefDecl *typeDecl ) {
    8787        handleNamedTypeDecl( typeDecl );
    8888        return typeDecl;
    8989}
    9090
    91 AsmDecl *Mutator::mutate( AsmDecl *asmDecl ) {
     91AsmDecl * Mutator::mutate( AsmDecl *asmDecl ) {
    9292        asmDecl->set_stmt( maybeMutate( asmDecl->get_stmt(), *this ) );
    9393        return asmDecl;
     
    9595
    9696
    97 CompoundStmt *Mutator::mutate( CompoundStmt *compoundStmt ) {
     97CompoundStmt * Mutator::mutate( CompoundStmt *compoundStmt ) {
    9898        mutateAll( compoundStmt->get_kids(), *this );
    9999        return compoundStmt;
    100100}
    101101
    102 Statement *Mutator::mutate( ExprStmt *exprStmt ) {
     102Statement * Mutator::mutate( ExprStmt *exprStmt ) {
    103103        exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) );
    104104        return exprStmt;
    105105}
    106106
    107 Statement *Mutator::mutate( AsmStmt *asmStmt ) {
     107Statement * Mutator::mutate( AsmStmt *asmStmt ) {
    108108        asmStmt->set_instruction( maybeMutate( asmStmt->get_instruction(), *this ) );
    109109        mutateAll( asmStmt->get_output(), *this );
     
    113113}
    114114
    115 Statement *Mutator::mutate( IfStmt *ifStmt ) {
     115Statement * Mutator::mutate( IfStmt *ifStmt ) {
    116116        mutateAll( ifStmt->get_initialization(), *this );
    117117        ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) );
     
    121121}
    122122
    123 Statement *Mutator::mutate( WhileStmt *whileStmt ) {
     123Statement * Mutator::mutate( WhileStmt *whileStmt ) {
    124124        whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) );
    125125        whileStmt->set_body( maybeMutate( whileStmt->get_body(), *this ) );
     
    127127}
    128128
    129 Statement *Mutator::mutate( ForStmt *forStmt ) {
     129Statement * Mutator::mutate( ForStmt *forStmt ) {
    130130        mutateAll( forStmt->get_initialization(), *this );
    131131        forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) );
     
    135135}
    136136
    137 Statement *Mutator::mutate( SwitchStmt *switchStmt ) {
     137Statement * Mutator::mutate( SwitchStmt *switchStmt ) {
    138138        switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
    139139        mutateAll( switchStmt->get_statements(), *this );
     
    141141}
    142142
    143 Statement *Mutator::mutate( CaseStmt *caseStmt ) {
     143Statement * Mutator::mutate( CaseStmt *caseStmt ) {
    144144        caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
    145145        mutateAll (caseStmt->get_statements(), *this );
     
    148148}
    149149
    150 Statement *Mutator::mutate( BranchStmt *branchStmt ) {
     150Statement * Mutator::mutate( BranchStmt *branchStmt ) {
    151151        return branchStmt;
    152152}
    153153
    154 Statement *Mutator::mutate( ReturnStmt *returnStmt ) {
     154Statement * Mutator::mutate( ReturnStmt *returnStmt ) {
    155155        returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) );
    156156        return returnStmt;
    157157}
    158158
    159 Statement *Mutator::mutate( ThrowStmt *throwStmt ) {
     159Statement * Mutator::mutate( ThrowStmt *throwStmt ) {
    160160        throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) );
    161161        throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) );
     
    163163}
    164164
    165 Statement *Mutator::mutate( TryStmt *tryStmt ) {
     165Statement * Mutator::mutate( TryStmt *tryStmt ) {
    166166        tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
    167167        mutateAll( tryStmt->get_catchers(), *this );
     
    170170}
    171171
    172 Statement *Mutator::mutate( CatchStmt *catchStmt ) {
     172Statement * Mutator::mutate( CatchStmt *catchStmt ) {
    173173        catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
    174174        catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
     
    177177}
    178178
    179 Statement *Mutator::mutate( FinallyStmt *finalStmt ) {
     179Statement * Mutator::mutate( FinallyStmt *finalStmt ) {
    180180        finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
    181181        return finalStmt;
    182182}
    183183
    184 NullStmt *Mutator::mutate( NullStmt *nullStmt ) {
     184Statement * Mutator::mutate( WaitForStmt *waitforStmt ) {
     185        for( auto & clause : waitforStmt->clauses ) {
     186                clause.target.function = maybeMutate( clause.target.function, *this );
     187                mutateAll( clause.target.arguments, *this );
     188
     189                clause.statement = maybeMutate( clause.statement, *this );
     190                clause.condition = maybeMutate( clause.condition, *this );
     191        }
     192
     193        waitforStmt->timeout.time      = maybeMutate( waitforStmt->timeout.time, *this );
     194        waitforStmt->timeout.statement = maybeMutate( waitforStmt->timeout.statement, *this );
     195        waitforStmt->timeout.condition = maybeMutate( waitforStmt->timeout.condition, *this );
     196        waitforStmt->orelse.statement  = maybeMutate( waitforStmt->orelse.statement, *this );
     197        waitforStmt->orelse.condition  = maybeMutate( waitforStmt->orelse.condition, *this );
     198
     199        return waitforStmt;
     200}
     201
     202NullStmt * Mutator::mutate( NullStmt *nullStmt ) {
    185203        return nullStmt;
    186204}
    187205
    188 Statement *Mutator::mutate( DeclStmt *declStmt ) {
     206Statement * Mutator::mutate( DeclStmt *declStmt ) {
    189207        declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
    190208        return declStmt;
    191209}
    192210
    193 Statement *Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
     211Statement * Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
    194212        impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) );
    195213        return impCtorDtorStmt;
     
    197215
    198216
    199 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
     217Expression * Mutator::mutate( ApplicationExpr *applicationExpr ) {
    200218        applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) );
    201219        applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
     
    205223}
    206224
    207 Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
     225Expression * Mutator::mutate( UntypedExpr *untypedExpr ) {
    208226        untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) );
    209227        untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
     
    212230}
    213231
    214 Expression *Mutator::mutate( NameExpr *nameExpr ) {
     232Expression * Mutator::mutate( NameExpr *nameExpr ) {
    215233        nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) );
    216234        nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
     
    218236}
    219237
    220 Expression *Mutator::mutate( AddressExpr *addressExpr ) {
     238Expression * Mutator::mutate( AddressExpr *addressExpr ) {
    221239        addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) );
    222240        addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
     
    225243}
    226244
    227 Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
     245Expression * Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
    228246        labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
    229247        labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
     
    232250}
    233251
    234 Expression *Mutator::mutate( CastExpr *castExpr ) {
     252Expression * Mutator::mutate( CastExpr *castExpr ) {
    235253        castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
    236254        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
     
    239257}
    240258
    241 Expression *Mutator::mutate( VirtualCastExpr *castExpr ) {
     259Expression * Mutator::mutate( VirtualCastExpr *castExpr ) {
    242260        castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
    243261        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
     
    246264}
    247265
    248 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
     266Expression * Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    249267        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
    250268        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
     
    254272}
    255273
    256 Expression *Mutator::mutate( MemberExpr *memberExpr ) {
     274Expression * Mutator::mutate( MemberExpr *memberExpr ) {
    257275        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
    258276        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
     
    261279}
    262280
    263 Expression *Mutator::mutate( VariableExpr *variableExpr ) {
     281Expression * Mutator::mutate( VariableExpr *variableExpr ) {
    264282        variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
    265283        variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
     
    267285}
    268286
    269 Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
     287Expression * Mutator::mutate( ConstantExpr *constantExpr ) {
    270288        constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
    271289        constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
     
    274292}
    275293
    276 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
     294Expression * Mutator::mutate( SizeofExpr *sizeofExpr ) {
    277295        sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
    278296        sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
     
    285303}
    286304
    287 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
     305Expression * Mutator::mutate( AlignofExpr *alignofExpr ) {
    288306        alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
    289307        alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
     
    296314}
    297315
    298 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
     316Expression * Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
    299317        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
    300318        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
     
    303321}
    304322
    305 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
     323Expression * Mutator::mutate( OffsetofExpr *offsetofExpr ) {
    306324        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
    307325        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
     
    311329}
    312330
    313 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
     331Expression * Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
    314332        offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
    315333        offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
     
    318336}
    319337
    320 Expression *Mutator::mutate( AttrExpr *attrExpr ) {
     338Expression * Mutator::mutate( AttrExpr *attrExpr ) {
    321339        attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
    322340        attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
     
    329347}
    330348
    331 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
     349Expression * Mutator::mutate( LogicalExpr *logicalExpr ) {
    332350        logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
    333351        logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
     
    337355}
    338356
    339 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
     357Expression * Mutator::mutate( ConditionalExpr *conditionalExpr ) {
    340358        conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
    341359        conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
     
    346364}
    347365
    348 Expression *Mutator::mutate( CommaExpr *commaExpr ) {
     366Expression * Mutator::mutate( CommaExpr *commaExpr ) {
    349367        commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
    350368        commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
     
    354372}
    355373
    356 Expression *Mutator::mutate( TypeExpr *typeExpr ) {
     374Expression * Mutator::mutate( TypeExpr *typeExpr ) {
    357375        typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
    358376        typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
     
    361379}
    362380
    363 Expression *Mutator::mutate( AsmExpr *asmExpr ) {
     381Expression * Mutator::mutate( AsmExpr *asmExpr ) {
    364382        asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
    365383        asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
     
    386404}
    387405
    388 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
     406Expression * Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
    389407        compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
    390408        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
     
    393411}
    394412
    395 Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
     413Expression * Mutator::mutate( RangeExpr *rangeExpr ) {
    396414        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
    397415        rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
     
    400418}
    401419
    402 Expression *Mutator::mutate( UntypedTupleExpr *tupleExpr ) {
     420Expression * Mutator::mutate( UntypedTupleExpr *tupleExpr ) {
    403421        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    404422        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     
    407425}
    408426
    409 Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
     427Expression * Mutator::mutate( TupleExpr *tupleExpr ) {
    410428        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    411429        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     
    414432}
    415433
    416 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
     434Expression * Mutator::mutate( TupleIndexExpr *tupleExpr ) {
    417435        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    418436        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     
    421439}
    422440
    423 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
     441Expression * Mutator::mutate( TupleAssignExpr *assignExpr ) {
    424442        assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
    425443        assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
     
    428446}
    429447
    430 Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
     448Expression * Mutator::mutate( StmtExpr *stmtExpr ) {
    431449        stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
    432450        stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
     
    437455}
    438456
    439 Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) {
     457Expression * Mutator::mutate( UniqueExpr *uniqueExpr ) {
    440458        uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
    441459        uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
     
    444462}
    445463
    446 Expression *Mutator::mutate( UntypedInitExpr * initExpr ) {
     464Expression * Mutator::mutate( UntypedInitExpr * initExpr ) {
    447465        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
    448466        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
     
    452470}
    453471
    454 Expression *Mutator::mutate( InitExpr * initExpr ) {
     472Expression * Mutator::mutate( InitExpr * initExpr ) {
    455473        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
    456474        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
     
    461479
    462480
    463 Type *Mutator::mutate( VoidType *voidType ) {
     481Type * Mutator::mutate( VoidType *voidType ) {
    464482        mutateAll( voidType->get_forall(), *this );
    465483        return voidType;
    466484}
    467485
    468 Type *Mutator::mutate( BasicType *basicType ) {
     486Type * Mutator::mutate( BasicType *basicType ) {
    469487        mutateAll( basicType->get_forall(), *this );
    470488        return basicType;
    471489}
    472490
    473 Type *Mutator::mutate( PointerType *pointerType ) {
     491Type * Mutator::mutate( PointerType *pointerType ) {
    474492        mutateAll( pointerType->get_forall(), *this );
    475493        pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
     
    477495}
    478496
    479 Type *Mutator::mutate( ArrayType *arrayType ) {
     497Type * Mutator::mutate( ArrayType *arrayType ) {
    480498        mutateAll( arrayType->get_forall(), *this );
    481499        arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
     
    484502}
    485503
    486 Type *Mutator::mutate( FunctionType *functionType ) {
     504Type * Mutator::mutate( FunctionType *functionType ) {
    487505        mutateAll( functionType->get_forall(), *this );
    488506        mutateAll( functionType->get_returnVals(), *this );
     
    491509}
    492510
    493 Type *Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
     511Type * Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
    494512        mutateAll( aggregateUseType->get_forall(), *this );
    495513        mutateAll( aggregateUseType->get_parameters(), *this );
     
    497515}
    498516
    499 Type *Mutator::mutate( StructInstType *aggregateUseType ) {
     517Type * Mutator::mutate( StructInstType *aggregateUseType ) {
    500518        handleReferenceToType( aggregateUseType );
    501519        return aggregateUseType;
    502520}
    503521
    504 Type *Mutator::mutate( UnionInstType *aggregateUseType ) {
     522Type * Mutator::mutate( UnionInstType *aggregateUseType ) {
    505523        handleReferenceToType( aggregateUseType );
    506524        return aggregateUseType;
    507525}
    508526
    509 Type *Mutator::mutate( EnumInstType *aggregateUseType ) {
     527Type * Mutator::mutate( EnumInstType *aggregateUseType ) {
    510528        handleReferenceToType( aggregateUseType );
    511529        return aggregateUseType;
    512530}
    513531
    514 Type *Mutator::mutate( TraitInstType *aggregateUseType ) {
     532Type * Mutator::mutate( TraitInstType *aggregateUseType ) {
    515533        handleReferenceToType( aggregateUseType );
    516534        mutateAll( aggregateUseType->get_members(), *this );
     
    518536}
    519537
    520 Type *Mutator::mutate( TypeInstType *aggregateUseType ) {
     538Type * Mutator::mutate( TypeInstType *aggregateUseType ) {
    521539        handleReferenceToType( aggregateUseType );
    522540        return aggregateUseType;
    523541}
    524542
    525 Type *Mutator::mutate( TupleType *tupleType ) {
     543Type * Mutator::mutate( TupleType *tupleType ) {
    526544        mutateAll( tupleType->get_forall(), *this );
    527545        mutateAll( tupleType->get_types(), *this );
     
    530548}
    531549
    532 Type *Mutator::mutate( TypeofType *typeofType ) {
     550Type * Mutator::mutate( TypeofType *typeofType ) {
    533551        assert( typeofType->get_expr() );
    534552        typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
     
    536554}
    537555
    538 Type *Mutator::mutate( AttrType *attrType ) {
     556Type * Mutator::mutate( AttrType *attrType ) {
    539557        if ( attrType->get_isType() ) {
    540558                assert( attrType->get_type() );
     
    547565}
    548566
    549 Type *Mutator::mutate( VarArgsType *varArgsType ) {
     567Type * Mutator::mutate( VarArgsType *varArgsType ) {
    550568        mutateAll( varArgsType->get_forall(), *this );
    551569        return varArgsType;
    552570}
    553571
    554 Type *Mutator::mutate( ZeroType *zeroType ) {
     572Type * Mutator::mutate( ZeroType *zeroType ) {
    555573        mutateAll( zeroType->get_forall(), *this );
    556574        return zeroType;
    557575}
    558576
    559 Type *Mutator::mutate( OneType *oneType ) {
     577Type * Mutator::mutate( OneType *oneType ) {
    560578        mutateAll( oneType->get_forall(), *this );
    561579        return oneType;
     
    563581
    564582
    565 Designation *Mutator::mutate( Designation * designation ) {
     583Designation * Mutator::mutate( Designation * designation ) {
    566584        mutateAll( designation->get_designators(), *this );
    567585        return designation;
    568586}
    569587
    570 Initializer *Mutator::mutate( SingleInit *singleInit ) {
     588Initializer * Mutator::mutate( SingleInit *singleInit ) {
    571589        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
    572590        return singleInit;
    573591}
    574592
    575 Initializer *Mutator::mutate( ListInit *listInit ) {
     593Initializer * Mutator::mutate( ListInit *listInit ) {
    576594        mutateAll( listInit->get_designations(), *this );
    577595        mutateAll( listInit->get_initializers(), *this );
     
    579597}
    580598
    581 Initializer *Mutator::mutate( ConstructorInit *ctorInit ) {
     599Initializer * Mutator::mutate( ConstructorInit *ctorInit ) {
    582600        ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
    583601        ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
     
    587605
    588606
    589 Subrange *Mutator::mutate( Subrange *subrange ) {
     607Subrange * Mutator::mutate( Subrange *subrange ) {
    590608        return subrange;
    591609}
    592610
    593611
    594 Constant *Mutator::mutate( Constant *constant ) {
     612Constant * Mutator::mutate( Constant *constant ) {
    595613        return constant;
    596614}
  • src/SynTree/Mutator.h

    r3eab0ef6 r135b431  
    4949        virtual Statement* mutate( CatchStmt *catchStmt );
    5050        virtual Statement* mutate( FinallyStmt *catchStmt );
     51        virtual Statement* mutate( WaitForStmt *waitforStmt );
    5152        virtual NullStmt* mutate( NullStmt *nullStmt );
    5253        virtual Statement* mutate( DeclStmt *declStmt );
  • src/SynTree/Statement.cc

    r3eab0ef6 r135b431  
    419419}
    420420
     421WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels ) {
     422        timeout.time      = nullptr;
     423        timeout.statement = nullptr;
     424        timeout.condition = nullptr;
     425        orelse .statement = nullptr;
     426        orelse .condition = nullptr;
     427}
     428
     429WaitForStmt::WaitForStmt( const WaitForStmt & other ) : Statement( other ) {
     430        clauses.reserve( other.clauses.size() );
     431        for( auto & ocl : other.clauses ) {
     432                clauses.emplace_back();
     433                clauses.back().target.function = ocl.target.function->clone();
     434                cloneAll( ocl.target.arguments, clauses.back().target.arguments );
     435                clauses.back().statement = ocl.statement->clone();
     436                clauses.back().condition = ocl.condition->clone();
     437        }
     438
     439        timeout.time      = other.timeout.time     ->clone();
     440        timeout.statement = other.timeout.statement->clone();
     441        timeout.condition = other.timeout.condition->clone();
     442        orelse .statement = other.orelse .statement->clone();
     443        orelse .condition = other.orelse .condition->clone();
     444}
     445
     446WaitForStmt::~WaitForStmt() {
     447        for( auto & clause : clauses ) {
     448                delete clause.target.function;
     449                deleteAll( clause.target.arguments );
     450                delete clause.statement;
     451                delete clause.condition;
     452        }
     453
     454        delete timeout.time;
     455        delete timeout.statement;
     456        delete timeout.condition;
     457
     458        delete orelse.statement;
     459        delete orelse.condition;
     460}
     461
     462void WaitForStmt::print( std::ostream &os, int indent ) const {
     463        os << "Waitfor Statement" << endl;
     464        os << string( indent + 2, ' ' ) << "with block:" << endl;
     465        os << string( indent + 4, ' ' );
     466        // block->print( os, indent + 4 );
     467}
     468
    421469NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {}
    422470NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
  • src/SynTree/Statement.h

    r3eab0ef6 r135b431  
    1919#include <list>                    // for list
    2020#include <memory>                  // for allocator
     21#include <vector>                        // for vector
    2122
    2223#include "BaseSyntaxNode.h"        // for BaseSyntaxNode
     
    392393};
    393394
     395class WaitForStmt : public Statement {
     396  public:
     397
     398        struct Target {
     399                Expression * function;
     400                std::list<Expression * > arguments;
     401        };
     402
     403        struct Clause {
     404                Target       target;
     405                Statement  * statement;
     406                Expression * condition;
     407        };
     408
     409        WaitForStmt( std::list<Label> labels = noLabels );
     410        WaitForStmt( const WaitForStmt & );
     411        virtual ~WaitForStmt();
     412
     413        std::vector<Clause> clauses;
     414
     415        struct {
     416                Expression * time;
     417                Statement  * statement;
     418                Expression * condition;
     419        } timeout;
     420
     421        struct {
     422                Statement  * statement;
     423                Expression * condition;
     424        } orelse;
     425
     426        virtual WaitForStmt *clone() const { return new WaitForStmt( *this ); }
     427        virtual void accept( Visitor &v ) { v.visit( this ); }
     428        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     429        virtual void print( std::ostream &os, int indent = 0 ) const;
     430
     431};
     432
    394433
    395434// represents a declaration that occurs as part of a compound statement
  • src/SynTree/SynTree.h

    r3eab0ef6 r135b431  
    5454class CatchStmt;
    5555class FinallyStmt;
     56class WaitForStmt;
    5657class NullStmt;
    5758class DeclStmt;
  • src/SynTree/Visitor.cc

    r3eab0ef6 r135b431  
    155155}
    156156
     157void Visitor::visit( WaitForStmt *waitforStmt ) {
     158        for( auto & clause : waitforStmt->clauses ) {
     159                maybeAccept( clause.target.function, *this );
     160                acceptAll( clause.target.arguments, *this );
     161
     162                maybeAccept( clause.statement, *this );
     163                maybeAccept( clause.condition, *this );
     164        }
     165
     166        maybeAccept( waitforStmt->timeout.time, *this );
     167        maybeAccept( waitforStmt->timeout.statement, *this );
     168        maybeAccept( waitforStmt->timeout.condition, *this );
     169        maybeAccept( waitforStmt->orelse.statement, *this );
     170        maybeAccept( waitforStmt->orelse.condition, *this );
     171}
     172
    157173void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) {
    158174}
  • src/SynTree/Visitor.h

    r3eab0ef6 r135b431  
    5151        virtual void visit( CatchStmt *catchStmt );
    5252        virtual void visit( FinallyStmt *finallyStmt );
     53        virtual void visit( WaitForStmt *waitforStmt );
    5354        virtual void visit( NullStmt *nullStmt );
    5455        virtual void visit( DeclStmt *declStmt );
  • src/libcfa/concurrency/kernel.c

    r3eab0ef6 r135b431  
    322322void ScheduleThread( thread_desc * thrd ) {
    323323        // if( !thrd ) return;
    324         assert( thrd );
    325         assert( thrd->cor.state != Halted );
     324        verify( thrd );
     325        verify( thrd->cor.state != Halted );
    326326
    327327        verify( disable_preempt_count > 0 );
Note: See TracChangeset for help on using the changeset viewer.