Changeset 0db6fc0 for src/ControlStruct


Ignore:
Timestamp:
Jun 2, 2017, 6:30:18 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
7985fa5
Parents:
f94ca7e
Message:

convert several passes to PassVisitor?

Location:
src/ControlStruct
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ForExprMutator.cc

    rf94ca7e r0db6fc0  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ForExprMutator.cc -- 
     7// ForExprMutator.cc --
    88//
    99// Author           : Rodolfo G. Esteves
     
    1919
    2020namespace ControlStruct {
    21         Statement *ForExprMutator::mutate( ForStmt *forStmt ) {
    22                 // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99)
    23                 forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) );
    24 
    25                 std::list<Statement *> &init = forStmt->get_initialization();
     21        Statement *ForExprMutator::postmutate( ForStmt *forStmt ) {
     22                // hoist any initializer declarations to make them C89 (rather than C99)
     23                std::list<Statement *> &init = forStmt->get_initialization();
    2624                if ( init.size() == 0 ) {
    2725                        return forStmt;
     
    3937                forStmt->set_initialization( std::list<Statement *>() );
    4038                return block;
    41 
    42                 return forStmt;
    4339        }
    4440} // namespace ControlStruct
  • src/ControlStruct/ForExprMutator.h

    rf94ca7e r0db6fc0  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ForExprMutator.h -- 
     7// ForExprMutator.h --
    88//
    99// Author           : Rodolfo G. Esteves
     
    2121
    2222namespace ControlStruct {
    23         class ForExprMutator : public Mutator {
     23        class ForExprMutator {
    2424          public:
    25                 virtual Statement *mutate( ForStmt * );
     25                Statement *postmutate( ForStmt * );
    2626        };
    2727} // namespace ControlStruct
  • src/ControlStruct/Mutate.cc

    rf94ca7e r0db6fc0  
    2626
    2727#include "Common/utility.h"
     28#include "Common/PassVisitor.h"
    2829
    2930#include "SynTree/Visitor.h"
     
    3435        void mutate( std::list< Declaration * > translationUnit ) {
    3536                // hoist initialization out of for statements
    36                 ForExprMutator formut;
     37                PassVisitor<ForExprMutator> formut;
    3738
    3839                // normalizes label definitions and generates multi-level exit labels
Note: See TracChangeset for help on using the changeset viewer.