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/Common/PassVisitor.impl.h

    r044ae62 rfa2c005  
    688688
    689689//--------------------------------------------------------------------------
     690// AdtDecl
     691template< typename pass_type >
     692void PassVisitor< pass_type >::visit( AdtDecl * node ) {
     693        VISIT_START( node );
     694
     695        indexerAddAdtFwd( node );
     696
     697        maybeAccept_impl( node->data_union, *this );
     698        maybeAccept_impl( node->tag, *this );
     699
     700        maybeAccept_impl( node->parameters, *this );
     701        maybeAccept_impl( node->members   , *this );
     702        maybeAccept_impl( node->attributes, *this );
     703
     704        indexerAddAdt( node );
     705
     706        VISIT_END( node );
     707}
     708
     709template< typename pass_type >
     710void PassVisitor< pass_type >::visit( const AdtDecl * node ) {
     711        VISIT_START( node );
     712
     713        indexerAddAdtFwd( node );
     714
     715        maybeAccept_impl( node->data_union, *this );
     716        maybeAccept_impl( node->tag, *this );
     717
     718        maybeAccept_impl( node->parameters, *this );
     719        maybeAccept_impl( node->members   , *this );
     720        maybeAccept_impl( node->attributes, *this );
     721
     722        indexerAddAdt( node );
     723
     724        VISIT_END( node );
     725
     726
     727template< typename pass_type >
     728Declaration * PassVisitor< pass_type >::mutate( AdtDecl * node ) {
     729        MUTATE_START( node );
     730       
     731        indexerAddAdtFwd( node );
     732
     733        maybeMutate_impl( node->data_union, *this );
     734        maybeMutate_impl( node->tag, *this );
     735
     736        maybeMutate_impl( node->parameters, *this );
     737        maybeMutate_impl( node->members   , *this );
     738        maybeMutate_impl( node->attributes, *this );
     739
     740        indexerAddAdt( node );
     741
     742        MUTATE_END( Declaration, node );
     743}
     744
     745
     746//--------------------------------------------------------------------------
    690747// UnionDecl
    691748template< typename pass_type >
     
    789846}
    790847
    791 template< typename pass_type >
    792 void PassVisitor< pass_type >::visit( AdtDecl * node ) {
    793         VISIT_START( node );
    794 
    795         indexerAddAdtFwd( node );
    796 
    797         // unlike structs, traits, and unions, enums inject their members into the global scope
    798         maybeAccept_impl( node->data_constructors, *this );
    799         maybeAccept_impl( node->data_union, *this );
    800         maybeAccept_impl( node->tag, *this );
    801 
    802         maybeAccept_impl( node->parameters, *this );
    803         maybeAccept_impl( node->members   , *this );
    804         maybeAccept_impl( node->attributes, *this );
    805 
    806         VISIT_END( node );
    807 }
    808 
    809 template< typename pass_type >
    810 void PassVisitor< pass_type >::visit( const AdtDecl * node ) {
    811         VISIT_START( node );
    812 
    813         indexerAddAdtFwd( node );
    814 
    815         maybeAccept_impl( node->data_constructors, *this );
    816         maybeAccept_impl( node->data_union, *this );
    817         maybeAccept_impl( node->tag, *this );
    818 
    819         maybeAccept_impl( node->parameters, *this );
    820         maybeAccept_impl( node->members   , *this );
    821         maybeAccept_impl( node->attributes, *this );
    822 
    823 
    824         VISIT_END( node );
    825 
    826 
    827 template< typename pass_type >
    828 Declaration * PassVisitor< pass_type >::mutate( AdtDecl * node ) {
    829         MUTATE_START( node );
    830        
    831         indexerAddAdtFwd( node );
    832 
    833         maybeMutate_impl( node->data_constructors, *this );
    834         maybeMutate_impl( node->data_union, *this );
    835         maybeMutate_impl( node->tag, *this );
    836 
    837         maybeMutate_impl( node->parameters, *this );
    838         maybeMutate_impl( node->members   , *this );
    839         maybeMutate_impl( node->attributes, *this );
    840 
    841         MUTATE_END( Declaration, node );
    842 }
    843848
    844849//--------------------------------------------------------------------------
     
    35403545
    35413546        indexerAddStruct( node->name );
     3547
     3548        {
     3549                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     3550                maybeMutate_impl( node->forall    , *this );
     3551                maybeMutate_impl( node->parameters, *this );
     3552        }
     3553
     3554        MUTATE_END( Type, node );
     3555}
     3556
     3557//--------------------------------------------------------------------------
     3558// AdtInstType
     3559template< typename pass_type >
     3560void PassVisitor< pass_type >::visit( AdtInstType * node ) {
     3561        VISIT_START( node );
     3562
     3563        indexerAddAdt( node->name );
     3564
     3565        {
     3566                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     3567                maybeAccept_impl( node->forall    , *this );
     3568                maybeAccept_impl( node->parameters, *this );
     3569        }
     3570
     3571        VISIT_END( node );
     3572}
     3573
     3574template< typename pass_type >
     3575void PassVisitor< pass_type >::visit( const AdtInstType * node ) {
     3576        VISIT_START( node );
     3577
     3578        indexerAddAdt( node->name );
     3579
     3580        {
     3581                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     3582                maybeAccept_impl( node->forall    , *this );
     3583                maybeAccept_impl( node->parameters, *this );
     3584        }
     3585
     3586        VISIT_END( node );
     3587}
     3588
     3589template< typename pass_type >
     3590Type * PassVisitor< pass_type >::mutate( AdtInstType * node ) {
     3591        MUTATE_START( node );
     3592
     3593        indexerAddAdt( node->name );
    35423594
    35433595        {
Note: See TracChangeset for help on using the changeset viewer.