Ignore:
Timestamp:
Jun 15, 2017, 12:18:23 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
637568b, 7b6ca2e
Parents:
f146716
Message:

Pass visitor:

  • added support for throw statment
  • now resets skip children flag after reading it
  • prototype for value guard alternative (Still un-tested)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    rf146716 r6e09f211  
    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); }
     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        }
    232246};
    233247
     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
    234255#include "PassVisitor.impl.h"
Note: See TracChangeset for help on using the changeset viewer.