Ignore:
Timestamp:
Jun 1, 2017, 4:26:50 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:
676cc8c
Parents:
3fb9a83
Message:

Refactored PassVisitor? to properly support env and statements to add

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r3fb9a83 r134322e  
    244244        ValueGuard(T& inRef) : old(inRef), ref(inRef) {}
    245245        ~ValueGuard() { ref = old; }
     246};
     247
     248template< typename T >
     249struct ValueGuardPtr {
     250        T old;
     251        T* ref;
     252
     253        ValueGuardPtr(T * inRef) : old( inRef ? *inRef : T() ), ref(inRef) {}
     254        ~ValueGuardPtr() { if( ref ) *ref = old; }
     255};
     256
     257template< typename T >
     258struct ValueGuardPtr< std::list< T > > {
     259        std::list< T > old;
     260        std::list< T >* ref;
     261
     262        ValueGuardPtr( std::list< T > * inRef) : old(), ref(inRef) {
     263                if( ref ) { swap( *ref, old ); }
     264        }
     265        ~ValueGuardPtr() { if( ref ) { swap( *ref, old ); } }
    246266};
    247267
Note: See TracChangeset for help on using the changeset viewer.