Changeset 7dc09294 for src/Common


Ignore:
Timestamp:
Sep 13, 2017, 7:27:12 AM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
982832e
Parents:
ada0eb06 (diff), 4639b0d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    rada0eb06 r7dc09294  
    145145        virtual Declaration* mutate( EnumDecl *aggregateDecl ) override final;
    146146        virtual Declaration* mutate( TraitDecl *aggregateDecl ) override final;
    147         virtual TypeDecl* mutate( TypeDecl *typeDecl ) override final;
     147        virtual Declaration* mutate( TypeDecl *typeDecl ) override final;
    148148        virtual Declaration* mutate( TypedefDecl *typeDecl ) override final;
    149149        virtual AsmDecl* mutate( AsmDecl *asmDecl ) override final;
  • src/Common/PassVisitor.impl.h

    rada0eb06 r7dc09294  
    976976
    977977template< typename pass_type >
    978 TypeDecl * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
    979         MUTATE_BODY( TypeDecl, node );
     978Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
     979        MUTATE_BODY( Declaration, node );
    980980}
    981981
  • src/Common/utility.h

    rada0eb06 r7dc09294  
    370370}
    371371
     372// -----------------------------------------------------------------------------
     373// Helper struct and function to support
     374// for ( val : lazy_map( container1, f ) ) {}
     375// syntax to have a for each that iterates a container, mapping each element by applying f
     376template< typename T, typename Func >
     377struct lambda_iterate_t {
     378        const T & ref;
     379        std::function<Func> f;
     380
     381        struct iterator {
     382                typedef decltype(begin(ref)) Iter;
     383                Iter it;
     384                std::function<Func> f;
     385                iterator( Iter it, std::function<Func> f ) : it(it), f(f) {}
     386                iterator & operator++() {
     387                        ++it; return *this;
     388                }
     389                bool operator!=( const iterator &other ) const { return it != other.it; }
     390                auto operator*() const -> decltype(f(*it)) { return f(*it); }
     391        };
     392
     393        lambda_iterate_t( const T & ref, std::function<Func> f ) : ref(ref), f(f) {}
     394
     395        auto begin() const -> decltype(iterator(std::begin(ref), f)) { return iterator(std::begin(ref), f); }
     396        auto end() const   -> decltype(iterator(std::end(ref), f)) { return iterator(std::end(ref), f); }
     397};
     398
     399template< typename... Args >
     400lambda_iterate_t<Args...> lazy_map( const Args &... args ) {
     401        return lambda_iterate_t<Args...>( args...);
     402}
     403
     404
     405
    372406// Local Variables: //
    373407// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.