Ignore:
Timestamp:
May 15, 2019, 10:15:44 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
be567e9
Parents:
712348a
Message:

Fixes to the new templated pass and started on conversions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.proto.hpp

    r712348a r6d51bd7  
    162162
    163163        // List of fields and their expected types
    164         FIELD_PTR( env, const ast::TypeSubstitution )
     164        FIELD_PTR( env, const ast::TypeSubstitution * )
    165165        FIELD_PTR( stmtsToAddBefore, std::list< ast::ptr< ast::Stmt > > )
    166166        FIELD_PTR( stmtsToAddAfter , std::list< ast::ptr< ast::Stmt > > )
     
    235235                static inline void func( pass_t &, long, type1, type2 ) {}
    236236
    237                 INDEXER_FUNC1( addId     , DeclWithType *  );
    238                 INDEXER_FUNC1( addType   , NamedTypeDecl * );
    239                 INDEXER_FUNC1( addStruct , StructDecl *    );
    240                 INDEXER_FUNC1( addEnum   , EnumDecl *      );
    241                 INDEXER_FUNC1( addUnion  , UnionDecl *     );
    242                 INDEXER_FUNC1( addTrait  , TraitDecl *     );
    243                 INDEXER_FUNC2( addWith   , std::list< Expression * > &, Node * );
     237                INDEXER_FUNC1( addId     , const DeclWithType *  );
     238                INDEXER_FUNC1( addType   , const NamedTypeDecl * );
     239                INDEXER_FUNC1( addStruct , const StructDecl *    );
     240                INDEXER_FUNC1( addEnum   , const EnumDecl *      );
     241                INDEXER_FUNC1( addUnion  , const UnionDecl *     );
     242                INDEXER_FUNC1( addTrait  , const TraitDecl *     );
     243                INDEXER_FUNC2( addWith   , const std::list< Expression * > &, const Node * );
    244244
    245245                // A few extra functions have more complicated behaviour, they are hand written
    246                 // template<typename pass_t>
    247                 // static inline auto addStructFwd( pass_t & pass, int, ast::StructDecl * decl ) -> decltype( pass.indexer.addStruct( decl ), void() ) {
    248                 //      ast::StructDecl * fwd = new ast::StructDecl( decl->location, decl->name );
    249                 //      fwd->parameters = decl->parameters;
    250                 //      pass.indexer.addStruct( fwd );
    251                 // }
    252 
    253                 // template<typename pass_t>
    254                 // static inline void addStructFwd( pass_t &, long, ast::StructDecl * ) {}
    255 
    256                 // template<typename pass_t>
    257                 // static inline auto addUnionFwd( pass_t & pass, int, ast::UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) {
    258                 //      UnionDecl * fwd = new UnionDecl( decl->name );
    259                 //      fwd->parameters = decl->parameters;
    260                 //      pass.indexer.addUnion( fwd );
    261                 // }
    262 
    263                 // template<typename pass_t>
    264                 // static inline void addUnionFwd( pass_t &, long, ast::UnionDecl * ) {}
    265 
    266                 // template<typename pass_t>
    267                 // static inline auto addStruct( pass_t & pass, int, const std::string & str ) -> decltype( pass.indexer.addStruct( str ), void() ) {
    268                 //      if ( ! pass.indexer.lookupStruct( str ) ) {
    269                 //              pass.indexer.addStruct( str );
    270                 //      }
    271                 // }
    272 
    273                 // template<typename pass_t>
    274                 // static inline void addStruct( pass_t &, long, const std::string & ) {}
    275 
    276                 // template<typename pass_t>
    277                 // static inline auto addUnion( pass_t & pass, int, const std::string & str ) -> decltype( pass.indexer.addUnion( str ), void() ) {
    278                 //      if ( ! pass.indexer.lookupUnion( str ) ) {
    279                 //              pass.indexer.addUnion( str );
    280                 //      }
    281                 // }
    282 
    283                 // template<typename pass_t>
    284                 // static inline void addUnion( pass_t &, long, const std::string & ) {}
     246                template<typename pass_t>
     247                static inline auto addStructFwd( pass_t & pass, int, const ast::StructDecl * decl ) -> decltype( pass.indexer.addStruct( decl ), void() ) {
     248                        ast::StructDecl * fwd = new ast::StructDecl( decl->location, decl->name );
     249                        fwd->parameters = decl->parameters;
     250                        pass.indexer.addStruct( fwd );
     251                }
     252
     253                template<typename pass_t>
     254                static inline void addStructFwd( pass_t &, long, const ast::StructDecl * ) {}
     255
     256                template<typename pass_t>
     257                static inline auto addUnionFwd( pass_t & pass, int, const ast::UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) {
     258                        UnionDecl * fwd = new UnionDecl( decl->location, decl->name );
     259                        fwd->parameters = decl->parameters;
     260                        pass.indexer.addUnion( fwd );
     261                }
     262
     263                template<typename pass_t>
     264                static inline void addUnionFwd( pass_t &, long, const ast::UnionDecl * ) {}
     265
     266                template<typename pass_t>
     267                static inline auto addStruct( pass_t & pass, int, const std::string & str ) -> decltype( pass.indexer.addStruct( str ), void() ) {
     268                        if ( ! pass.indexer.lookupStruct( str ) ) {
     269                                pass.indexer.addStruct( str );
     270                        }
     271                }
     272
     273                template<typename pass_t>
     274                static inline void addStruct( pass_t &, long, const std::string & ) {}
     275
     276                template<typename pass_t>
     277                static inline auto addUnion( pass_t & pass, int, const std::string & str ) -> decltype( pass.indexer.addUnion( str ), void() ) {
     278                        if ( ! pass.indexer.lookupUnion( str ) ) {
     279                                pass.indexer.addUnion( str );
     280                        }
     281                }
     282
     283                template<typename pass_t>
     284                static inline void addUnion( pass_t &, long, const std::string & ) {}
    285285
    286286                #undef INDEXER_FUNC1
Note: See TracChangeset for help on using the changeset viewer.