// // 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. // // MLEMutator.cc -- // // Author : Rodolfo G. Esteves // Created On : Mon May 18 07:44:20 2015 // Last Modified By : Rob Schluntz // Last Modified On : Mon Jul 20 13:58:35 2015 // Update Count : 176 // // NOTE: There are two known subtle differences from the code that uC++ // generates for the same input // -CFA puts the break label inside at the end of a switch, uC++ puts it after // -CFA puts the break label after a block, uC++ puts it inside at the end // we don't yet know if these differences are important, but if they are then // the fix would go in this file, since this is where these labels are generated. #include #include #include "MLEMutator.h" #include "SynTree/Statement.h" #include "SynTree/Expression.h" #include "SynTree/Attribute.h" namespace ControlStruct { MLEMutator::~MLEMutator() { delete targetTable; targetTable = 0; } namespace { Statement * isLoop( Statement * stmt ) { return dynamic_cast< WhileStmt * >( stmt ) ? stmt : dynamic_cast< ForStmt * >( stmt ) ? stmt : 0; } } // break labels have to come after the statement they break out of, // so mutate a statement, then if they inform us through the breakLabel field // tha they need a place to jump to on a break statement, add the break label // to the body of statements void MLEMutator::fixBlock( std::list< Statement * > &kids ) { for ( std::list< Statement * >::iterator k = kids.begin(); k != kids.end(); k++ ) { *k = (*k)->acceptMutator(*this); if ( ! get_breakLabel().empty() ) { std::list< Statement * >::iterator next = k+1; std::list