Changeset 982832e for src/Common


Ignore:
Timestamp:
Sep 13, 2017, 2:44:01 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:
ba54f7d, c935c3a
Parents:
e3e16bc (diff), 7dc09294 (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

    re3e16bc r982832e  
    147147        virtual Declaration* mutate( EnumDecl *aggregateDecl ) override final;
    148148        virtual Declaration* mutate( TraitDecl *aggregateDecl ) override final;
    149         virtual TypeDecl* mutate( TypeDecl *typeDecl ) override final;
     149        virtual Declaration* mutate( TypeDecl *typeDecl ) override final;
    150150        virtual Declaration* mutate( TypedefDecl *typeDecl ) override final;
    151151        virtual AsmDecl* mutate( AsmDecl *asmDecl ) override final;
  • src/Common/PassVisitor.impl.h

    re3e16bc r982832e  
    506506
    507507template< typename pass_type >
    508 TypeDecl * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
     508Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
    509509        MUTATE_START( node );
    510510
     
    521521        indexerScopedMutate( node->init, *this );
    522522
    523         MUTATE_END( TypeDecl, node );
     523        MUTATE_END( Declaration, node );
    524524}
    525525
  • src/Common/utility.h

    re3e16bc r982832e  
    389389}
    390390
     391// -----------------------------------------------------------------------------
     392// Helper struct and function to support
     393// for ( val : lazy_map( container1, f ) ) {}
     394// syntax to have a for each that iterates a container, mapping each element by applying f
     395template< typename T, typename Func >
     396struct lambda_iterate_t {
     397        const T & ref;
     398        std::function<Func> f;
     399
     400        struct iterator {
     401                typedef decltype(begin(ref)) Iter;
     402                Iter it;
     403                std::function<Func> f;
     404                iterator( Iter it, std::function<Func> f ) : it(it), f(f) {}
     405                iterator & operator++() {
     406                        ++it; return *this;
     407                }
     408                bool operator!=( const iterator &other ) const { return it != other.it; }
     409                auto operator*() const -> decltype(f(*it)) { return f(*it); }
     410        };
     411
     412        lambda_iterate_t( const T & ref, std::function<Func> f ) : ref(ref), f(f) {}
     413
     414        auto begin() const -> decltype(iterator(std::begin(ref), f)) { return iterator(std::begin(ref), f); }
     415        auto end() const   -> decltype(iterator(std::end(ref), f)) { return iterator(std::end(ref), f); }
     416};
     417
     418template< typename... Args >
     419lambda_iterate_t<Args...> lazy_map( const Args &... args ) {
     420        return lambda_iterate_t<Args...>( args...);
     421}
     422
     423
     424
    391425// Local Variables: //
    392426// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.