Changeset f4e01f1


Ignore:
Timestamp:
May 17, 2023, 4:27:25 PM (14 months ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT
Children:
3a513d89
Parents:
d6c464d
Message:

Save progress

Location:
src
Files:
6 edited

Legend:

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

    rd6c464d rf4e01f1  
    430430
    431431        template<typename core_t>
     432        static inline auto addAdtFwd( core_t & core, int, const ast::AdtDecl * decl ) -> decltype( core.symtab.addAdt( decl ), void() ) {
     433                ast::AdtDecl * fwd = new ast::AdtDecl( decl->location, decl->name );
     434                for ( const auto & param : decl->params ) {
     435                        fwd->params.push_back( deepCopy( param.get() ) );
     436                }
     437                // Experimental
     438                for ( const auto & ctor : decl->data_constructors ) {
     439                        addStructFwd( core, 0, ctor  );
     440                }
     441                core.symtab.addAdt( fwd );
     442        }
     443
     444        template<typename core_t>
     445        static inline auto addAdtFwd( core_t &, long, const ast::AdtDecl) {}
     446
     447        template<typename core_t>
    432448        static inline auto addStruct( core_t & core, int, const std::string & str ) -> decltype( core.symtab.addStruct( str ), void() ) {
    433449                if ( ! core.symtab.lookupStruct( str ) ) {
  • src/CodeGen/CodeGenerator.cc

    rd6c464d rf4e01f1  
    295295        }
    296296
    297         void CodeGenerator::handleData( EnumDecl * dataDecl ) {
     297        void CodeGenerator::handleData( EnumDecl * ) {
    298298                // output << " /** data type */" << endl;
    299299                // for ( StructDecl * decl : dataDecl->data_constructors ) {
     
    348348                        } // if
    349349                } // if
     350        }
     351
     352        void CodeGenerator::postvisit( AdtDecl * ) {
     353                // TODO
    350354        }
    351355
  • src/CodeGen/CodeGenerator.h

    rd6c464d rf4e01f1  
    5353                void postvisit( UnionDecl * aggregateDecl );
    5454                void postvisit( EnumDecl * aggregateDecl );
     55                void postvisit( AdtDecl * AggregateDecl );
    5556                void postvisit( TraitDecl * aggregateDecl );
    5657                void postvisit( TypedefDecl * typeDecl );
  • src/Common/PassVisitor.h

    rd6c464d rf4e01f1  
    443443        void indexerAddEnum     ( const EnumDecl            * node  ) { indexer_impl_addEnum     ( pass, 0, node ); }
    444444        void indexerAddAdt              ( const AdtDecl                         * node  ) { indexer_impl_addAdt          ( pass, 0, node ); }
     445        void indexerAddAdtFwd   ( const AdtDecl                         * node  ) { indexer_impl_addAdtFwd   ( pass, 0, node  ); }
    445446        void indexerAddUnion    ( const std::string         & id    ) { indexer_impl_addUnion    ( pass, 0, id   ); }
    446447        void indexerAddUnion    ( const UnionDecl           * node  ) { indexer_impl_addUnion    ( pass, 0, node ); }
  • src/Common/PassVisitor.impl.h

    rd6c464d rf4e01f1  
    793793        VISIT_START( node );
    794794
    795         indexerAddAdt( node );
     795        indexerAddAdtFwd( node );
    796796
    797797        // unlike structs, traits, and unions, enums inject their members into the global scope
     
    811811        VISIT_START( node );
    812812
     813        indexerAddAdtFwd( node );
     814
    813815        maybeAccept_impl( node->data_constructors, *this );
    814816        maybeAccept_impl( node->data_union, *this );
     
    826828Declaration * PassVisitor< pass_type >::mutate( AdtDecl * node ) {
    827829        MUTATE_START( node );
     830       
     831        indexerAddAdtFwd( node );
    828832
    829833        maybeMutate_impl( node->data_constructors, *this );
  • src/Common/PassVisitor.proto.h

    rd6c464d rf4e01f1  
    252252
    253253template<typename pass_type>
     254static inline auto indexer_impl_addAdtFwd( pass_type & pass, int, const AdtDecl * decl ) -> decltype( pass.indexer.addAdt( decl ), void() ) {
     255        AdtDecl * fwd = new AdtDecl( decl->name );
     256        cloneAll( decl->parameters, fwd->parameters );
     257
     258        // Experimental
     259        for ( const StructDecl * ctor : fwd->data_constructors ) {
     260                indexer_impl_addStructFwd( pass, 0, ctor );
     261        }
     262
     263        pass.indexer.addAdt( fwd );
     264}
     265
     266template<typename pass_type>
     267static inline auto indexer_impl_addAdtFwd( pass_type &, long, const AdtDecl * ) {}
     268
     269template<typename pass_type>
    254270static inline auto indexer_impl_addUnionFwd( pass_type & pass, int, const UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) {
    255271        UnionDecl * fwd = new UnionDecl( decl->name );
Note: See TracChangeset for help on using the changeset viewer.