Changeset fa2c005 for src/Common
- Timestamp:
- Jun 8, 2023, 3:19:43 PM (2 years ago)
- Branches:
- ADT
- Parents:
- 044ae62
- Location:
- src/Common
- Files:
-
- 4 edited
-
CodeLocationTools.cpp (modified) (1 diff)
-
PassVisitor.h (modified) (3 diffs)
-
PassVisitor.impl.h (modified) (3 diffs)
-
PassVisitor.proto.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/CodeLocationTools.cpp
r044ae62 rfa2c005 185 185 macro(FunctionType, Type) \ 186 186 macro(StructInstType, Type) \ 187 macro(AdtInstType, Type) \ 187 188 macro(UnionInstType, Type) \ 188 189 macro(EnumInstType, Type) \ -
src/Common/PassVisitor.h
r044ae62 rfa2c005 226 226 virtual void visit( StructInstType * aggregateUseType ) override final; 227 227 virtual void visit( const StructInstType * aggregateUseType ) override final; 228 virtual void visit( AdtInstType * aggregateUseType ) override final; 229 virtual void visit( const AdtInstType * aggregateUseType ) override final; 228 230 virtual void visit( UnionInstType * aggregateUseType ) override final; 229 231 virtual void visit( const UnionInstType * aggregateUseType ) override final; … … 351 353 virtual Type * mutate( FunctionType * functionType ) override final; 352 354 virtual Type * mutate( StructInstType * aggregateUseType ) override final; 355 virtual Type * mutate( AdtInstType * aggregateUseType ) override final; 353 356 virtual Type * mutate( UnionInstType * aggregateUseType ) override final; 354 357 virtual Type * mutate( EnumInstType * aggregateUseType ) override final; … … 442 445 void indexerAddStructFwd( const StructDecl * node ) { indexer_impl_addStructFwd( pass, 0, node ); } 443 446 void indexerAddEnum ( const EnumDecl * node ) { indexer_impl_addEnum ( pass, 0, node ); } 447 void indexerAddAdt ( const std::string & id ) { indexer_impl_addAdt ( pass, 0, id ); } 444 448 void indexerAddAdt ( const AdtDecl * node ) { indexer_impl_addAdt ( pass, 0, node ); } 445 449 void indexerAddAdtFwd ( const AdtDecl * node ) { indexer_impl_addAdtFwd ( pass, 0, node ); } -
src/Common/PassVisitor.impl.h
r044ae62 rfa2c005 688 688 689 689 //-------------------------------------------------------------------------- 690 // AdtDecl 691 template< typename pass_type > 692 void 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 709 template< typename pass_type > 710 void 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 727 template< typename pass_type > 728 Declaration * 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 //-------------------------------------------------------------------------- 690 747 // UnionDecl 691 748 template< typename pass_type > … … 789 846 } 790 847 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 scope798 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 }843 848 844 849 //-------------------------------------------------------------------------- … … 3540 3545 3541 3546 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 3559 template< typename pass_type > 3560 void 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 3574 template< typename pass_type > 3575 void 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 3589 template< typename pass_type > 3590 Type * PassVisitor< pass_type >::mutate( AdtInstType * node ) { 3591 MUTATE_START( node ); 3592 3593 indexerAddAdt( node->name ); 3542 3594 3543 3595 { -
src/Common/PassVisitor.proto.h
r044ae62 rfa2c005 256 256 cloneAll( decl->parameters, fwd->parameters ); 257 257 258 // Experimental259 for ( const StructDecl * ctor : fwd->data_constructors ) {260 indexer_impl_addStructFwd( pass, 0, ctor );261 }262 263 258 pass.indexer.addAdt( fwd ); 264 259 } … … 288 283 289 284 template<typename pass_type> 285 static inline auto indexer_impl_addAdt( pass_type & pass, int, const std::string & str ) -> decltype( pass.indexer.addAdt( str ), void() ) { 286 assert( false ); 287 if ( ! pass.indexer.lookupAdt( str )) { 288 pass.indexer.addAdt( str ); 289 } 290 } 291 292 template<typename pass_type> 293 static inline auto indexer_impl_addAdt( pass_type &, long, const std::string & ) { 294 assert( false ); 295 } 296 297 template<typename pass_type> 290 298 static inline auto indexer_impl_addUnion( pass_type & pass, int, const std::string & str ) -> decltype( pass.indexer.addUnion( str ), void() ) { 291 299 if ( ! pass.indexer.lookupUnion( str ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.