Changes in / [7b2c8c3c:34c32f0]


Ignore:
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r7b2c8c3c r34c32f0  
    10501050        VISIT_START( node );
    10511051
     1052<<<<<<< HEAD
     1053        VISIT(
     1054                maybe_accept( node, &MutexStmt::mutexObjs );
     1055                {
     1056                        // mutex statements introduce a level of scope (for the initialization)
     1057                        guard_symtab guard { *this };
     1058                        maybe_accept( node, &MutexStmt::stmt );
     1059                       
     1060                }
     1061        )
     1062=======
    10521063        if ( __visit_children() ) {
    10531064                // mutex statements introduce a level of scope (for the initialization)
     
    10561067                maybe_accept( node, &MutexStmt::mutexObjs );
    10571068        }
     1069>>>>>>> e21f2536b7495654ded040259b42b7e2325b8360
    10581070
    10591071        VISIT_END( Stmt, node );
  • src/ControlStruct/MultiLevelExit.cpp

    r7b2c8c3c r34c32f0  
    7171        bool isFallDefaultTarget() const { return kind == SwitchStmtK; }
    7272
     73        // These routines set a target as being "used" by a BranchStmt
    7374        Label useContExit() { assert( kind <= WhileStmtK ); return useTarget(secondTarget); }
    7475        Label useBreakExit() { assert( kind != CaseStmtK ); return useTarget(firstTarget); }
     
    7677        Label useFallDefaultExit() { assert( kind == SwitchStmtK ); return useTarget(secondTarget); }
    7778
     79        // These routines check if a specific label for a statement is used by a BranchStmt
    7880        bool isContUsed() const { assert( kind <= WhileStmtK ); return secondTarget.used; }
    7981        bool isBreakUsed() const { assert( kind != CaseStmtK ); return firstTarget.used; }
     
    164166        const CompoundStmt * stmt ) {
    165167        visit_children = false;
     168
     169        // if the stmt is labelled then generate a label to check in postvisit if the label is used
    166170        bool isLabeled = !stmt->labels.empty();
    167171        if ( isLabeled ) {
     
    217221}
    218222
     223// This routine updates targets on enclosing control structures to indicate which
     224//     label is used by the BranchStmt that is passed
    219225const BranchStmt * MultiLevelExitCore::postvisit( const BranchStmt * stmt ) {
    220226        vector<Entry>::reverse_iterator targetEntry =
    221227                enclosing_control_structures.rend();
     228
     229        // Labels on different stmts require different approaches to access
    222230        switch ( stmt->kind ) {
    223231          case BranchStmt::Goto:
     
    253261                  break;
    254262          }
     263          // handle fallthrough in case/switch stmts
    255264          case BranchStmt::FallThrough: {
    256265                  targetEntry = findEnclosingControlStructure( isFallthroughTarget );
     
    530539        }
    531540
     541        // if continue is used insert a continue label into the back of the body of the loop
    532542        if ( entry.isContUsed() ) {
    533543                CompoundStmt * new_body = new CompoundStmt( body->location );
     544                // {}
    534545                new_body->kids.push_back( body );
     546                // {
     547                //  body
     548                // }
    535549                new_body->kids.push_back(
    536550                        labelledNullStmt( body->location, entry.useContExit() ) );
     551                // {
     552                //  body
     553                //  ContinueLabel: {}
     554                // }
    537555                return new_body;
    538556        }
     
    548566        Label contLabel = newLabel( "loopContinue", loopStmt );
    549567        enclosing_control_structures.emplace_back( loopStmt, breakLabel, contLabel );
     568        // labels are added temporarily to see if they are used and then added permanently in postvisit if ther are used
     569        // children will tag labels as being used during their traversal which occurs before postvisit
     570
     571        // GuardAction calls the lambda after the node is done being visited
    550572        GuardAction( [this](){ enclosing_control_structures.pop_back(); } );
    551573}
     
    560582        return mutate_field(
    561583                loopStmt, &LoopNode::body, mutateLoop( loopStmt->body, entry ) );
     584        // this call to mutate_field compares loopStmt->body and the result of mutateLoop
     585        //              if they are the same the node isn't mutated, if they differ then the new mutated node is returned
     586        //              the stmts will only differ if a label is used
    562587}
    563588
Note: See TracChangeset for help on using the changeset viewer.