Ignore:
Timestamp:
Apr 25, 2024, 3:48:17 PM (17 months ago)
Author:
JiadaL <j82liang@…>
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.
Message:

resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CommonType.cc

    rcf191ac r7042c60  
    3636namespace ResolvExpr {
    3737
     38namespace {
     39
    3840        // GENERATED START, DO NOT EDIT
    3941        // GENERATED BY BasicTypes-gen.cc
     
    397399                        }
    398400                } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) {
    399             if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) {
    400                             ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];
    401                             if (
    402                                     ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
    403                                             || widen.first )
    404                                     && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers )
    405                                             || widen.second )
    406                             ) {
    407                                     result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers };
    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                        }
    410412                }
    411413        }
     
    519521                                                                // xxx - assume LHS is always the target type
    520522
    521                                                                 if ( ! ((widen.second && ref2->qualifiers.is_mutex) 
     523                                                                if ( ! ((widen.second && ref2->qualifiers.is_mutex)
    522524                                                                || (ref1->qualifiers.is_mutex == ref2->qualifiers.is_mutex ))) return;
    523525
     
    710712// size_t CommonType::traceId = Stats::Heap::new_stacktrace_id("CommonType");
    711713
    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;
     714ast::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 ) ) {
    725730                        PRINT(
    726                                 std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl;
     731                                std::cerr << "widen okay" << std::endl;
    727732                        )
    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 };
    742742}
     743
     744} // namespace
    743745
    744746ast::ptr< ast::Type > commonType(
     
    781783        }
    782784        // 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 );
    788787}
    789788
Note: See TracChangeset for help on using the changeset viewer.