ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 16cfd8c was
d3b7937,
checked in by Peter A. Buhr <pabuhr@…>, 9 years ago
|
building runtime library (first attempt)
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[51587aa] | 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 | // |
---|
[a08ba92] | 7 | // DeclarationHoister.cc -- |
---|
[51587aa] | 8 | // |
---|
[843054c2] | 9 | // Author : Rodolfo G. Esteves |
---|
[51587aa] | 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[a08ba92] | 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Tue May 19 16:33:20 2015 |
---|
| 13 | // Update Count : 2 |
---|
[51587aa] | 14 | // |
---|
[a08ba92] | 15 | |
---|
[51b7345] | 16 | #include <list> |
---|
| 17 | #include <cassert> |
---|
| 18 | #include <iostream> |
---|
| 19 | #include <iterator> |
---|
| 20 | #include <algorithm> |
---|
| 21 | |
---|
[d3b7937] | 22 | #include "Common/utility.h" |
---|
[51b7345] | 23 | |
---|
| 24 | #include "SynTree/Statement.h" |
---|
| 25 | #include "SynTree/Expression.h" |
---|
| 26 | #include "SynTree/Declaration.h" |
---|
| 27 | |
---|
| 28 | #include "DeclarationHoister.h" |
---|
| 29 | |
---|
| 30 | namespace InitTweak { |
---|
[a08ba92] | 31 | CompoundStmt* DeclarationHoister::mutate( CompoundStmt *compoundStmt ) { |
---|
| 32 | typedef std::list<Statement *>::iterator stmt_it; |
---|
| 33 | // 1. collect Declaration Statements in this scope |
---|
| 34 | std::list<Statement *> &kids = compoundStmt->get_kids(); |
---|
| 35 | std::list<Statement *>::iterator result = kids.begin(); |
---|
| 36 | std::list< stmt_it > decls; |
---|
| 37 | |
---|
| 38 | while ( result != kids.end() ) { |
---|
| 39 | result = std::find_if (result, kids.end(), cast_ptr< Statement, DeclStmt > ); |
---|
| 40 | |
---|
| 41 | if ( result != kids.end() ) { |
---|
| 42 | decls.push_back( result ); |
---|
| 43 | std::advance( result, 1 ); |
---|
| 44 | } // if |
---|
| 45 | } // while |
---|
| 46 | |
---|
| 47 | for ( std::list< stmt_it >::reverse_iterator i = decls.rbegin(); i!= decls.rend(); i++ ) { |
---|
| 48 | kids.push_front( **i ); |
---|
| 49 | kids.erase( *i ); |
---|
| 50 | } // for |
---|
| 51 | |
---|
| 52 | return compoundStmt; |
---|
| 53 | } |
---|
[51b7345] | 54 | } // namespace InitTweak |
---|
| 55 | |
---|
[51587aa] | 56 | // Local Variables: // |
---|
| 57 | // tab-width: 4 // |
---|
| 58 | // mode: c++ // |
---|
| 59 | // compile-command: "make install" // |
---|
| 60 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.