Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    rd7dc824 r4eb31f2b  
    5454        virtual void visit( BranchStmt *branchStmt ) override final;
    5555        virtual void visit( ReturnStmt *returnStmt ) override final;
     56        virtual void visit( ThrowStmt *throwStmt ) override final;
    5657        virtual void visit( TryStmt *tryStmt ) override final;
    5758        virtual void visit( CatchStmt *catchStmt ) override final;
     
    139140        virtual Statement* mutate( BranchStmt *branchStmt ) override final;
    140141        virtual Statement* mutate( ReturnStmt *returnStmt ) override final;
     142        virtual Statement* mutate( ThrowStmt *throwStmt ) override final;
    141143        virtual Statement* mutate( TryStmt *returnStmt ) override final;
    142144        virtual Statement* mutate( CatchStmt *catchStmt ) override final;
     
    230232        std::list< Statement* > *       get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); }
    231233        bool visit_children() { bool* skip = skip_children_impl(pass, 0); return ! (skip && *skip); }
    232 };
     234        void reset_visit() { bool* skip = skip_children_impl(pass, 0); if(skip) *skip = false; }
     235
     236        guard_value_impl init_guard() {
     237                guard_value_impl guard;
     238                auto at_cleanup = at_cleanup_impl(pass, 0);
     239                if( at_cleanup ) {
     240                        *at_cleanup = [&guard]( cleanup_func_t && func, void* val ) {
     241                                guard.push( std::move( func ), val );
     242                        };
     243                }
     244                return guard;
     245        }
     246};
     247
     248template<typename pass_type, typename T>
     249void GuardValue( pass_type * pass, T& val ) {
     250        pass->at_cleanup( [ val ]( void * newVal ) {
     251                * static_cast< T * >( newVal ) = val;
     252        }, static_cast< void * >( & val ) );
     253}
     254
     255class WithTypeSubstitution {
     256protected:
     257        WithTypeSubstitution() = default;
     258        ~WithTypeSubstitution() = default;
     259
     260public:
     261        TypeSubstitution * env;
     262};
     263
     264class WithStmtsToAdd {
     265protected:
     266        WithStmtsToAdd() = default;
     267        ~WithStmtsToAdd() = default;
     268
     269public:
     270        std::list< Statement* > stmtsToAddBefore;
     271        std::list< Statement* > stmtsToAddAfter;
     272};
     273
     274class WithShortCircuiting {
     275protected:
     276        WithShortCircuiting() = default;
     277        ~WithShortCircuiting() = default;
     278
     279public:
     280        bool skip_children;
     281};
     282
     283class WithScopes {
     284protected:
     285        WithScopes() = default;
     286        ~WithScopes() = default;
     287
     288public:
     289        at_cleanup_t at_cleanup;
     290
     291        template< typename T >
     292        void GuardValue( T& val ) {
     293                at_cleanup( [ val ]( void * newVal ) {
     294                        * static_cast< T * >( newVal ) = val;
     295                }, static_cast< void * >( & val ) );
     296        }
     297};
     298
    233299
    234300#include "PassVisitor.impl.h"
Note: See TracChangeset for help on using the changeset viewer.