ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change
on this file since 01aeade was
51587aa,
checked in by Peter A. Buhr <pabuhr@…>, 9 years ago
|
licencing: fourth groups of files
|
-
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 | // |
---|
| 7 | // XXX.cc -- |
---|
| 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
| 11 | // Last Modified By : |
---|
| 12 | // Last Modified On : |
---|
| 13 | // Update Count : 0 |
---|
| 14 | // |
---|
[51b7345] | 15 | #include <list> |
---|
| 16 | #include <cassert> |
---|
| 17 | #include <iostream> |
---|
| 18 | #include <iterator> |
---|
| 19 | #include <algorithm> |
---|
| 20 | |
---|
| 21 | #include "utility.h" |
---|
| 22 | |
---|
| 23 | #include "SynTree/Statement.h" |
---|
| 24 | #include "SynTree/Expression.h" |
---|
| 25 | #include "SynTree/Declaration.h" |
---|
| 26 | |
---|
| 27 | #include "DeclarationHoister.h" |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | namespace InitTweak { |
---|
| 31 | |
---|
| 32 | CompoundStmt* DeclarationHoister::mutate(CompoundStmt *compoundStmt) { |
---|
| 33 | typedef std::list<Statement *>::iterator stmt_it; |
---|
| 34 | // 1. collect Declaration Statements in this scope |
---|
| 35 | std::list<Statement *> &kids = compoundStmt->get_kids(); |
---|
| 36 | std::list<Statement *>::iterator result = kids.begin(); |
---|
| 37 | std::list< stmt_it > decls; |
---|
| 38 | |
---|
| 39 | while ( result != kids.end() ) { |
---|
[a32b204] | 40 | result = std::find_if (result, kids.end(), cast_ptr< Statement, DeclStmt > ); |
---|
[51b7345] | 41 | |
---|
| 42 | if ( result != kids.end() ) { |
---|
| 43 | decls.push_back( result ); |
---|
| 44 | std::advance( result, 1 ); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
[a32b204] | 48 | for ( std::list< stmt_it >::reverse_iterator i = decls.rbegin(); i!= decls.rend(); i++ ){ |
---|
[51b7345] | 49 | kids.push_front( **i ); |
---|
| 50 | kids.erase( *i ); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | return compoundStmt; |
---|
| 54 | } |
---|
| 55 | } // namespace InitTweak |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
[51587aa] | 64 | // Local Variables: // |
---|
| 65 | // tab-width: 4 // |
---|
| 66 | // mode: c++ // |
---|
| 67 | // compile-command: "make install" // |
---|
| 68 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.