aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // TupleAssignment.cc -- |
---|
8 | // |
---|
9 | // Author : Rodolfo G. Esteves |
---|
10 | // Created On : Mon May 18 07:44:20 2015 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Mon May 18 15:02:53 2015 |
---|
13 | // Update Count : 2 |
---|
14 | // |
---|
15 | |
---|
16 | #include <iterator> |
---|
17 | #include <iostream> |
---|
18 | #include <cassert> |
---|
19 | #include "Tuples.h" |
---|
20 | #include "GenPoly/PolyMutator.h" |
---|
21 | #include "SynTree/Statement.h" |
---|
22 | |
---|
23 | namespace Tuples { |
---|
24 | class TupleAssignExpander : public GenPoly::PolyMutator { |
---|
25 | public: |
---|
26 | virtual Expression * mutate( TupleAssignExpr * tupleExpr ); |
---|
27 | }; |
---|
28 | |
---|
29 | void expandTuples( std::list< Declaration * > & translationUnit ) { |
---|
30 | TupleAssignExpander expander; |
---|
31 | mutateAll( translationUnit, expander ); |
---|
32 | } |
---|
33 | |
---|
34 | Expression * TupleAssignExpander::mutate( TupleAssignExpr * tupleExpr ) { |
---|
35 | CompoundStmt * compoundStmt = new CompoundStmt( noLabels ); |
---|
36 | std::list< Statement * > & stmts = compoundStmt->get_kids(); |
---|
37 | for ( ObjectDecl * obj : tupleExpr->get_tempDecls() ) { |
---|
38 | stmts.push_back( new DeclStmt( noLabels, obj ) ); |
---|
39 | } |
---|
40 | for ( Expression * assign : tupleExpr->get_assigns() ) { |
---|
41 | stmts.push_back( new ExprStmt( noLabels, assign ) ); |
---|
42 | } |
---|
43 | tupleExpr->get_tempDecls().clear(); |
---|
44 | tupleExpr->get_assigns().clear(); |
---|
45 | delete tupleExpr; |
---|
46 | return new StmtExpr( compoundStmt ); |
---|
47 | } |
---|
48 | |
---|
49 | } // namespace Tuples |
---|
50 | |
---|
51 | // Local Variables: // |
---|
52 | // tab-width: 4 // |
---|
53 | // mode: c++ // |
---|
54 | // compile-command: "make install" // |
---|
55 | // End: // |
---|
56 | |
---|
Note: See
TracBrowser
for help on using the repository browser.