Changeset 7042c60 for src/ResolvExpr/CommonType.cc
- Timestamp:
- Apr 25, 2024, 3:48:17 PM (17 months ago)
- Branches:
- master
- Children:
- eb7586e
- Parents:
- cf191ac (diff), 55c97e4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CommonType.cc
rcf191ac r7042c60 36 36 namespace ResolvExpr { 37 37 38 namespace { 39 38 40 // GENERATED START, DO NOT EDIT 39 41 // GENERATED BY BasicTypes-gen.cc … … 397 399 } 398 400 } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) { 399 400 401 402 403 404 405 406 407 408 409 401 if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) { 402 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ]; 403 if ( 404 ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers ) 405 || widen.first ) 406 && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers ) 407 || widen.second ) 408 ) { 409 result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers }; 410 } 411 } 410 412 } 411 413 } … … 519 521 // xxx - assume LHS is always the target type 520 522 521 if ( ! ((widen.second && ref2->qualifiers.is_mutex) 523 if ( ! ((widen.second && ref2->qualifiers.is_mutex) 522 524 || (ref1->qualifiers.is_mutex == ref2->qualifiers.is_mutex ))) return; 523 525 … … 710 712 // size_t CommonType::traceId = Stats::Heap::new_stacktrace_id("CommonType"); 711 713 712 namespace { 713 ast::ptr< ast::Type > handleReference( 714 const ast::ptr< ast::Type > & t1, const ast::ptr< ast::Type > & t2, WidenMode widen, 715 ast::TypeEnvironment & env, 716 const ast::OpenVarSet & open 717 ) { 718 ast::ptr<ast::Type> common; 719 ast::AssertionSet have, need; 720 ast::OpenVarSet newOpen{ open }; 721 722 // need unify to bind type variables 723 if ( unify( t1, t2, env, have, need, newOpen, common ) ) { 724 ast::CV::Qualifiers q1 = t1->qualifiers, q2 = t2->qualifiers; 714 ast::ptr< ast::Type > handleReference( 715 const ast::ptr< ast::Type > & t1, const ast::ptr< ast::Type > & t2, WidenMode widen, 716 ast::TypeEnvironment & env, 717 const ast::OpenVarSet & open 718 ) { 719 ast::ptr<ast::Type> common; 720 ast::AssertionSet have, need; 721 ast::OpenVarSet newOpen( open ); 722 723 // need unify to bind type variables 724 if ( unify( t1, t2, env, have, need, newOpen, common ) ) { 725 ast::CV::Qualifiers q1 = t1->qualifiers, q2 = t2->qualifiers; 726 PRINT( 727 std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl; 728 ) 729 if ( ( widen.first || q2 <= q1 ) && ( widen.second || q1 <= q2 ) ) { 725 730 PRINT( 726 std::cerr << " unify success: " << widenFirst << " " << widenSecond<< std::endl;731 std::cerr << "widen okay" << std::endl; 727 732 ) 728 if ( ( widen.first || q2 <= q1 ) && ( widen.second || q1 <= q2 ) ) { 729 PRINT( 730 std::cerr << "widen okay" << std::endl; 731 ) 732 add_qualifiers( common, q1 | q2 ); 733 return common; 734 } 735 } 736 737 PRINT( 738 std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl; 739 ) 740 return { nullptr }; 741 } 733 add_qualifiers( common, q1 | q2 ); 734 return common; 735 } 736 } 737 738 PRINT( 739 std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl; 740 ) 741 return { nullptr }; 742 742 } 743 744 } // namespace 743 745 744 746 ast::ptr< ast::Type > commonType( … … 781 783 } 782 784 // otherwise both are reference types of the same depth and this is handled by the visitor 783 ast::Pass<CommonType> visitor{ type2, widen, env, open, need, have }; 784 type1->accept( visitor ); 785 // ast::ptr< ast::Type > result = visitor.core.result; 786 787 return visitor.core.result; 785 return ast::Pass<CommonType>::read( type1.get(), 786 type2, widen, env, open, need, have ); 788 787 } 789 788
Note:
See TracChangeset
for help on using the changeset viewer.