Ignore:
Timestamp:
May 19, 2015, 4:58:14 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
843054c2
Parents:
01aeade
Message:

licencing: sixth groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/InitTweak/DeclarationHoister.cc

    r01aeade ra08ba92  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// DeclarationHoister.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 16:33:20 2015
     13// Update Count     : 2
    1414//
     15
    1516#include <list>
    1617#include <cassert>
     
    2728#include "DeclarationHoister.h"
    2829
     30namespace InitTweak {
     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;
    2937
    30 namespace InitTweak {
     38                while ( result !=  kids.end() ) {
     39                        result = std::find_if (result, kids.end(), cast_ptr< Statement, DeclStmt > );
    3140
    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;
     41                        if ( result != kids.end() ) {
     42                                decls.push_back( result );
     43                                std::advance( result, 1 );
     44                        } // if
     45                } // while
    3846
    39     while ( result !=  kids.end() ) {
    40       result = std::find_if (result, kids.end(), cast_ptr< Statement, DeclStmt > );
     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
    4151
    42       if ( result != kids.end() ) {
    43         decls.push_back( result );
    44         std::advance( result, 1 );
    45       }
    46     }
    47 
    48     for ( std::list< stmt_it >::reverse_iterator i = decls.rbegin(); i!= decls.rend(); i++ ){
    49       kids.push_front( **i );
    50       kids.erase( *i );
    51     }
    52 
    53     return compoundStmt;
    54   }
     52                return compoundStmt;
     53        }
    5554} // namespace InitTweak
    56 
    57 
    58 
    59 
    60 
    61 
    62 
    6355
    6456// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.