#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