Ignore:
Timestamp:
Jun 23, 2017, 12:12:46 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:
2a7b3ca
Parents:
ba915fb5
Message:

convert more passes to PassVisitor?, fix PassVisitor? constructor bug, add WithDeclsToAdd? parent class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    rba915fb5 rd24d4e1  
    2626//                          stmtsToAddBefore or stmtsToAddAfter respectively.
    2727// | WithShortCircuiting  - provides the ability to skip visiting child nodes; set visit_children to false in pre{visit,mutate} to skip visiting children
    28 // | WithScopes           - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable
     28// | WithGuards           - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable
    2929//                          will automatically be restored to its previous value after the corresponding postvisit/postmutate teminates.
    3030//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    3232class PassVisitor final : public Visitor, public Mutator {
    3333public:
    34         PassVisitor() = default;
    3534
    3635        template< typename... Args >
     
    283282
    284283public:
    285         TypeSubstitution * env;
     284        TypeSubstitution * env = nullptr;
    286285};
    287286
     
    295294        std::list< Statement* > stmtsToAddAfter;
    296295};
     296
     297class WithDeclsToAdd {
     298protected:
     299        WithDeclsToAdd() = default;
     300        ~WithDeclsToAdd() = default;
     301
     302public:
     303        std::list< Declaration* > declsToAddBefore;
     304        std::list< Declaration* > declsToAddAfter;
     305};
     306
    297307class WithShortCircuiting {
    298308protected:
     
    304314};
    305315
    306 class WithScopes {
    307 protected:
    308         WithScopes() = default;
    309         ~WithScopes() = default;
     316class WithGuards {
     317protected:
     318        WithGuards() = default;
     319        ~WithGuards() = default;
    310320
    311321public:
     
    319329        }
    320330
     331        template< typename T >
     332        void GuardScope( T& val ) {
     333                val.beginScope();
     334                at_cleanup( []( void * val ) {
     335                        static_cast< T * >( val )->endScope();
     336                }, static_cast< void * >( & val ) );
     337        }
     338
    321339        template< typename Func >
    322         void GuardAction( Func&& func ) {
    323                 at_cleanup( std::forward<Func>( func ) );
     340        void GuardAction( Func func ) {
     341                at_cleanup( [func](__attribute__((unused)) void *) { func(); }, nullptr );
    324342        }
    325343};
     
    328346class WithVisitorRef {
    329347protected:
    330         WithVisitorRef() = default;
    331         ~WithVisitorRef() = default;
    332 
    333 public:
    334         PassVisitor<pass_type> * const visitor;
     348        WithVisitorRef() {}
     349        ~WithVisitorRef() {}
     350
     351public:
     352        PassVisitor<pass_type> * const visitor = nullptr;
    335353};
    336354
Note: See TracChangeset for help on using the changeset viewer.