Changeset 982832e for src/Common
- Timestamp:
- Sep 13, 2017, 2:44:01 PM (7 years ago)
- 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. - Location:
- src/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
re3e16bc r982832e 147 147 virtual Declaration* mutate( EnumDecl *aggregateDecl ) override final; 148 148 virtual Declaration* mutate( TraitDecl *aggregateDecl ) override final; 149 virtual TypeDecl* mutate( TypeDecl *typeDecl ) override final;149 virtual Declaration* mutate( TypeDecl *typeDecl ) override final; 150 150 virtual Declaration* mutate( TypedefDecl *typeDecl ) override final; 151 151 virtual AsmDecl* mutate( AsmDecl *asmDecl ) override final; -
src/Common/PassVisitor.impl.h
re3e16bc r982832e 506 506 507 507 template< typename pass_type > 508 TypeDecl* PassVisitor< pass_type >::mutate( TypeDecl * node ) {508 Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) { 509 509 MUTATE_START( node ); 510 510 … … 521 521 indexerScopedMutate( node->init, *this ); 522 522 523 MUTATE_END( TypeDecl, node );523 MUTATE_END( Declaration, node ); 524 524 } 525 525 -
src/Common/utility.h
re3e16bc r982832e 389 389 } 390 390 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 395 template< typename T, typename Func > 396 struct 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 418 template< typename... Args > 419 lambda_iterate_t<Args...> lazy_map( const Args &... args ) { 420 return lambda_iterate_t<Args...>( args...); 421 } 422 423 424 391 425 // Local Variables: // 392 426 // tab-width: 4 //
Note: See TracChangeset
for help on using the changeset viewer.