// // 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. // // TupleAssignment.cc -- // // Author : Rodolfo G. Esteves // Created On : Mon May 18 07:44:20 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Mon May 18 15:02:53 2015 // Update Count : 2 // #include #include #include #include "Tuples.h" #include "GenPoly/PolyMutator.h" #include "SynTree/Statement.h" namespace Tuples { class TupleAssignExpander : public GenPoly::PolyMutator { public: virtual Expression * mutate( TupleAssignExpr * tupleExpr ); }; void expandTuples( std::list< Declaration * > & translationUnit ) { TupleAssignExpander expander; mutateAll( translationUnit, expander ); } Expression * TupleAssignExpander::mutate( TupleAssignExpr * tupleExpr ) { CompoundStmt * compoundStmt = new CompoundStmt( noLabels ); std::list< Statement * > & stmts = compoundStmt->get_kids(); for ( ObjectDecl * obj : tupleExpr->get_tempDecls() ) { stmts.push_back( new DeclStmt( noLabels, obj ) ); } for ( Expression * assign : tupleExpr->get_assigns() ) { stmts.push_back( new ExprStmt( noLabels, assign ) ); } tupleExpr->get_tempDecls().clear(); tupleExpr->get_assigns().clear(); delete tupleExpr; return new StmtExpr( compoundStmt ); } } // namespace Tuples // Local Variables: // // tab-width: 4 // // mode: c++ // // compile-command: "make install" // // End: //