Ignore:
Timestamp:
Sep 13, 2017, 2:08:43 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:
aa72198
Parents:
b3f252a
Message:

Indexer merge with pass visitor completed but disabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.proto.h

    rb3f252a re0886db  
    4141};
    4242
    43 
    4443class bool_ref {
    4544public:
     
    5958        bool * m_ref;
    6059};
     60
     61template< typename TreeType, typename VisitorType >
     62inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
     63        // auto guard = makeFuncGuard(
     64        //      [&visitor]() { visitor.indexerScopeEnter(); },
     65        //      [&visitor]() { visitor.indexerScopeLeave(); }
     66        // );
     67        maybeAccept( tree, visitor );
     68}
     69
     70template< typename TreeType, typename MutatorType >
     71inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
     72        // auto guard = makeFuncGuard(
     73        //      [&mutator]() { mutator.indexerScopeEnter(); },
     74        //      [&mutator]() { mutator.indexerScopeLeave(); }
     75        // );
     76        tree = maybeMutate( tree, mutator );
     77}
     78
     79template< typename TreeType, typename MutatorType >
     80inline void maybeMutateRef( TreeType *& tree, MutatorType & mutator ) {
     81        tree = maybeMutate( tree, mutator );
     82}
    6183
    6284//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    93115static inline void postvisit_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) node_type * node, __attribute__((unused)) long unused ) {}
    94116
     117//---------------------------------------------------------
    95118// Mutate
    96119template<typename pass_type, typename node_type>
     
    111134static inline return_type postmutate_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) { return node; }
    112135
     136//---------------------------------------------------------
    113137// Begin/End scope
    114138template<typename pass_type>
     
    129153static inline void end_scope_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) long unused ) {}
    130154
     155//---------------------------------------------------------
    131156// Fields
    132157#define FIELD_PTR( type, name )                                                                                                        \
     
    145170FIELD_PTR( at_cleanup_t, at_cleanup )
    146171FIELD_PTR( PassVisitor<pass_type> * const, visitor )
     172
     173//---------------------------------------------------------
     174// Indexer
     175template<typename pass_type>
     176static inline auto indexer_impl_enterScope( pass_type & pass, int ) -> decltype( pass.indexer.enterScope(), void() ) {
     177        // pass.indexer.enterScope();
     178}
     179
     180template<typename pass_type>
     181static inline auto indexer_impl_enterScope( pass_type &, int ) {}
     182
     183template<typename pass_type>
     184static inline auto indexer_impl_leaveScope( pass_type & pass, int ) -> decltype( pass.indexer.leaveScope(), void() ) {
     185        // pass.indexer.leaveScope();
     186}
     187
     188template<typename pass_type>
     189static inline auto indexer_impl_leaveScope( pass_type &, int ) {}
     190
     191
     192#define INDEXER_FUNC( func, type )                                                                                             \
     193template<typename pass_type>                                                                                                   \
     194static inline auto indexer_impl_##func ( pass_type & pass, int, type arg ) -> decltype( pass.indexer.func( arg ), void() ) {   \
     195        /*pass.indexer.func( arg );*/                                                                                                \
     196}                                                                                                                              \
     197                                                                                                                               \
     198template<typename pass_type>                                                                                                   \
     199static inline void indexer_impl_##func ( pass_type &, long, type ) {}                                                          \
     200
     201INDEXER_FUNC( addId     , DeclarationWithType * );
     202INDEXER_FUNC( addType   , NamedTypeDecl *       );
     203INDEXER_FUNC( addStruct , StructDecl *          );
     204INDEXER_FUNC( addEnum   , EnumDecl *            );
     205INDEXER_FUNC( addUnion  , UnionDecl *           );
     206INDEXER_FUNC( addTrait  , TraitDecl *           );
     207
     208
     209template<typename pass_type>
     210static inline auto indexer_impl_addStructFwd( pass_type & pass, int, StructDecl * decl ) -> decltype( pass.indexer.addStruct( decl ), void() ) {
     211        // StructDecl * fwd = new StructDecl( decl->name );
     212        // cloneAll( decl->parameters, fwd->parameters );
     213        // pass.indexer.addStruct( fwd );
     214}
     215
     216template<typename pass_type>
     217static inline auto indexer_impl_addStructFwd( pass_type &, int, StructDecl * ) {}
     218
     219template<typename pass_type>
     220static inline auto indexer_impl_addUnionFwd( pass_type & pass, int, UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) {
     221        // UnionDecl * fwd = new UnionDecl( decl->name );
     222        // cloneAll( decl->parameters, fwd->parameters );
     223        // pass.indexer.addUnion( fwd );
     224}
     225
     226template<typename pass_type>
     227static inline auto indexer_impl_addUnionFwd( pass_type &, int, UnionDecl * ) {}
     228
     229template<typename pass_type>
     230static inline auto indexer_impl_addStruct( pass_type & pass, int, const std::string & str ) -> decltype( pass.indexer.addStruct( str ), void() ) {
     231        // if ( ! pass.indexer.lookupStruct( str ) ) {
     232        //      pass.indexer.addStruct( str );
     233        // }
     234}
     235
     236template<typename pass_type>
     237static inline auto indexer_impl_addStruct( pass_type &, int, const std::string & ) {}
     238
     239template<typename pass_type>
     240static inline auto indexer_impl_addUnion( pass_type & pass, int, const std::string & str ) -> decltype( pass.indexer.addUnion( str ), void() ) {
     241        // if ( ! pass.indexer.lookupUnion( str ) ) {
     242        //      pass.indexer.addUnion( str );
     243        // }
     244}
     245
     246template<typename pass_type>
     247static inline auto indexer_impl_addUnion( pass_type &, int, const std::string & ) {}
Note: See TracChangeset for help on using the changeset viewer.