// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // CaseRangeMutator.cc -- // // Author : Rodolfo G. Esteves // Created On : Mon May 18 07:44:20 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Tue May 19 13:00:28 2015 // Update Count : 3 // #include #include #include #include #include "utility.h" #include "SynTree/Statement.h" #include "SynTree/Expression.h" #include "SynTree/Constant.h" #include "SynTree/Type.h" #include "CaseRangeMutator.h" namespace ControlStruct { Statement *CaseRangeMutator::mutate( ChooseStmt *chooseStmt ) { // There shouldn't be any `choose' statements by now, throw an exception or something. throw( 0 ) ; /* FIXME */ } Statement *CaseRangeMutator::mutate( SwitchStmt *switchStmt ) { std::list< Statement * > &cases = switchStmt->get_branches(); // a `for' would be more natural... all this contortions are because `replace' invalidates the iterator std::list< Statement * >::iterator i = cases.begin(); while ( i != cases.end() ) { (*i )->acceptMutator( *this ); if ( ! newCaseLabels.empty() ) { std::list< Statement * > newCases; // transform( newCaseLabels.begin(), newCaseLabels.end(), bnd1st( ptr_fun( ctor< CaseStmt, Label, Expression * > ) ) ); for ( std::list< Expression * >::iterator j = newCaseLabels.begin(); j != newCaseLabels.end(); j++ ) { std::list