Ignore:
Timestamp:
Jun 8, 2023, 3:19:43 PM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT
Parents:
044ae62
Message:

Finish Adt POC

File:
1 edited

Legend:

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

    r044ae62 rfa2c005  
    477477
    478478        template<typename core_t>
     479        static inline auto addAdtFwd( core_t & core, int, const ast::AdtDecl * decl ) -> decltype( core.symtab.addAdt( decl ), void() ) {
     480                ast::AdtDecl * fwd = new ast::AdtDecl( decl->location, decl->name );
     481                for ( const auto & param : decl->params ) {
     482                        fwd->params.push_back( deepCopy( param.get() ) );
     483                }
     484                core.symtab.addAdt( fwd );
     485        }
     486
     487        template<typename core_t>
     488        static inline auto addAdtFwd( core_t &, long, const ast::AdtDecl * ) {}
     489
     490        template<typename core_t>
    479491        static inline auto addUnionFwd( core_t & core, int, const ast::UnionDecl * decl ) -> decltype( core.symtab.addUnion( decl ), void() ) {
    480492                ast::UnionDecl * fwd = new ast::UnionDecl( decl->location, decl->name );
     
    489501
    490502        template<typename core_t>
    491         static inline auto addAdtFwd( core_t & core, int, const ast::AdtDecl * decl ) -> decltype( core.symtab.addAdt( decl ), void() ) {
    492                 ast::AdtDecl * fwd = new ast::AdtDecl( decl->location, decl->name );
    493                 for ( const auto & param : decl->params ) {
    494                         fwd->params.push_back( deepCopy( param.get() ) );
    495                 }
    496                 // Experimental
    497                 for ( const auto & ctor : decl->data_constructors ) {
    498                         addStructFwd( core, 0, ctor  );
    499                 }
    500                 core.symtab.addAdt( fwd );
    501         }
    502 
    503         template<typename core_t>
    504         static inline auto addAdtFwd( core_t &, long, const ast::AdtDecl) {}
    505 
    506         template<typename core_t>
    507503        static inline auto addStruct( core_t & core, int, const std::string & str ) -> decltype( core.symtab.addStruct( str ), void() ) {
    508504                if ( ! core.symtab.lookupStruct( str ) ) {
     
    513509        template<typename core_t>
    514510        static inline void addStruct( core_t &, long, const std::string & ) {}
     511
     512                template<typename core_t>
     513        static inline auto addAdt( core_t & core, int, const std::string & str ) -> decltype( core.symtab.addAdt( str ), void() ) {
     514                if ( ! core.symtab.lookupAdt( str ) ) {
     515                        core.symtab.addAdt( str );
     516                }
     517        }
     518
     519        template<typename core_t>
     520        static inline void addAdt( core_t &, long, const std::string & ) {}
    515521
    516522        template<typename core_t>
Note: See TracChangeset for help on using the changeset viewer.