Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/LabelFixer.cc

    r1fbeebd rd180746  
    3737        }
    3838
    39         void LabelFixer::previsit( FunctionDecl * ) {
     39        void LabelFixer::visit( FunctionDecl *functionDecl ) {
    4040                // need to go into a nested function in a fresh state
    41                 GuardValue( labelTable );
     41                std::map < Label, Entry *> oldLabelTable = labelTable;
    4242                labelTable.clear();
    43         }
    4443
    45         void LabelFixer::postvisit( FunctionDecl * functionDecl ) {
     44                maybeAccept( functionDecl->get_statements(), *this );
     45
    4646                MLEMutator mlemut( resolveJumps(), generator );
    4747                functionDecl->acceptMutator( mlemut );
     48
     49                // and remember the outer function's labels when
     50                // returning to it
     51                labelTable = oldLabelTable;
    4852        }
    4953
    5054        // prune to at most one label definition for each statement
    51         void LabelFixer::previsit( Statement *stmt ) {
     55        void LabelFixer::visit( Statement *stmt ) {
    5256                std::list< Label > &labels = stmt->get_labels();
    5357
     
    5862        }
    5963
    60         void LabelFixer::previsit( BranchStmt *branchStmt ) {
    61                 previsit( ( Statement *)branchStmt );
     64        void LabelFixer::visit( BranchStmt *branchStmt ) {
     65                visit ( ( Statement * )branchStmt );
    6266
    6367                // for labeled branches, add an entry to the label table
     
    6872        }
    6973
    70         void LabelFixer::previsit( LabelAddressExpr * addrExpr ) {
    71                 Label & target = addrExpr->arg;
    72                 assert( target != "" );
    73                 setLabelsUsg( target, addrExpr );
     74        void LabelFixer::visit( UntypedExpr *untyped ) {
     75                if ( NameExpr * func = dynamic_cast< NameExpr * >( untyped->get_function() ) ) {
     76                        if ( func->get_name() == "&&" ) {
     77                                NameExpr * arg = dynamic_cast< NameExpr * >( untyped->get_args().front() );
     78                                Label target = arg->get_name();
     79                                assert( target != "" );
     80                                setLabelsUsg( target, untyped );
     81                        } else {
     82                                Visitor::visit( untyped );
     83                        }
     84                }
    7485        }
    7586
Note: See TracChangeset for help on using the changeset viewer.