Changeset 38093ae for src/ResolvExpr


Ignore:
Timestamp:
Apr 18, 2024, 8:44:24 PM (12 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
19313be5, cf191ac
Parents:
748c751 (diff), 7a780ad (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

Location:
src/ResolvExpr
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/ResolvExpr/CandidateFinder.cpp

    r748c751 r38093ae  
    13821382                                }
    13831383                        }
    1384                        
     1384
    13851385                        CandidateRef newCand = std::make_shared<Candidate>(
    13861386                                newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, bentConversion? Cost::safe: Cost::zero,
     
    17761776                                                auto commonAsEnumAttr = common.as<ast::EnumAttrType>();
    17771777                                                if ( commonAsEnumAttr && commonAsEnumAttr->attr == ast::EnumAttribute::Value ) {
    1778                                                        
    17791778                                                        auto callExpr = new ast::UntypedExpr(
    17801779                                                                cand->expr->location, new ast::NameExpr( cand->expr->location, "valueE"), {cand->expr} );
     
    18051804                                                        // if this somehow changes in the future (e.g. delayed by indeterminate return type)
    18061805                                                        // we may need to revisit the logic.
    1807                                                         inferParameters( newCand, matches );   
     1806                                                        inferParameters( newCand, matches );
    18081807                                                }
    1809                                         }                       
    1810                                 }       
     1808                                        }
     1809                                }
    18111810                        }
    18121811                }
     
    21612160                        }
    21622161                ),
    2163                 new ast::BasicType( ast::BasicType::SignedInt )
     2162                new ast::BasicType( ast::BasicKind::SignedInt )
    21642163        );
    21652164}
  • TabularUnified src/ResolvExpr/CandidateFinder.hpp

    r748c751 r38093ae  
    3030struct CandidateFinder {
    3131        CandidateList candidates;          ///< List of candidate resolutions
    32         const ResolveContext & context;  ///< Information about where the canditates are being found.
     32        const ResolveContext & context;    ///< Information about where the canditates are being found.
    3333        const ast::TypeEnvironment & env;  ///< Substitutions performed in this resolution
    3434        ast::ptr< ast::Type > targetType;  ///< Target type for resolution
    3535        bool strictMode = false;           ///< If set to true, requires targetType to be exact match (inside return cast)
    3636        bool allowVoid = false;            ///< If set to true, allow void-returning function calls (only top level, cast to void and first in comma)
    37         std::set< std::string > otypeKeys;  /// different type may map to same key
     37        std::set< std::string > otypeKeys; ///< different type may map to same key
    3838
    3939        CandidateFinder(
     
    7070        const ast::Expr * expr, Cost & cost );
    7171
    72 const ast::Expr * getValueEnumCall(const ast::Expr * expr,
    73         const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env );
     72/// Get the valueE application that returns the enum's value.
     73const ast::Expr * getValueEnumCall( const ast::Expr * expr,
     74        const ResolveContext & context, const ast::TypeEnvironment & env );
     75
    7476/// Wrap an expression to convert the result to a conditional result.
    7577const ast::Expr * createCondExpr( const ast::Expr * expr );
  • TabularUnified src/ResolvExpr/CommonType.cc

    r748c751 r38093ae  
    3838        // GENERATED START, DO NOT EDIT
    3939        // GENERATED BY BasicTypes-gen.cc
    40         #define BT ast::BasicType::
    41         static const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor
     40        #define BT ast::BasicKind::
     41        static const ast::BasicKind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor
    4242                /*                                      B                       C                      SC                      UC                      SI                     SUI
    4343                                                        I                      UI                      LI                     LUI                     LLI                    LLUI
     
    339339        // GENERATED END
    340340        static_assert(
    341                 sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
     341                sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES,
    342342                "Each basic type kind should have a corresponding row in the combined type matrix"
    343343        );
     
    366366        void postvisit( const ast::BasicType * basic ) {
    367367                if ( auto basic2 = dynamic_cast< const ast::BasicType * >( type2 ) ) {
    368                         ast::BasicType::Kind kind;
     368                        ast::BasicKind kind;
    369369                        if (basic->kind != basic2->kind && !widen.first && !widen.second) return;
    370370                        else if (!widen.first) kind = basic->kind; // widen.second
     
    386386                        const ast::EnumDecl* enumDecl = enumInst->base;
    387387                        if ( !enumDecl->base ) {
    388                                 ast::BasicType::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];
     388                                ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];
    389389                                if (
    390390                                        ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
     
    398398                } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) {
    399399            if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) {
    400                             ast::BasicType::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];
     400                            ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];
    401401                            if (
    402402                                    ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
     
    649649        void postvisit( const ast::EnumInstType * enumInst ) {
    650650                if ( enumInst->base && !enumInst->base->base ) {
    651                         auto basicType = new ast::BasicType( ast::BasicType::UnsignedInt );
     651                        auto basicType = new ast::BasicType( ast::BasicKind::UnsignedInt );
    652652                        result = commonType( basicType, type2, tenv, need, have, open, widen);
    653653                }
     
    674674                } else if ( widen.second && dynamic_cast< const ast::OneType * >( type2 ) ) {
    675675                        result = new ast::BasicType{
    676                                 ast::BasicType::SignedInt, zero->qualifiers | type2->qualifiers };
     676                                ast::BasicKind::SignedInt, zero->qualifiers | type2->qualifiers };
    677677                } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
    678678                        const ast::EnumDecl * enumDecl = enumInst->base;
     
    695695                } else if ( widen.second && dynamic_cast< const ast::ZeroType * >( type2 ) ) {
    696696                        result = new ast::BasicType{
    697                                 ast::BasicType::SignedInt, one->qualifiers | type2->qualifiers };
     697                                ast::BasicKind::SignedInt, one->qualifiers | type2->qualifiers };
    698698                } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
    699699                        const ast::EnumDecl * enumDecl = enumInst->base;
  • TabularUnified src/ResolvExpr/ConversionCost.cc

    r748c751 r38093ae  
    5959        // GENERATED START, DO NOT EDIT
    6060        // GENERATED BY BasicTypes-gen.cc
    61         static const int costMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
     61        static const int costMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
    6262                /*               B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    6363                /*      B */ {   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  15,  16,  17,  16,  18,  17, },
     
    101101        // GENERATED END
    102102        static_assert(
    103                 sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
     103                sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES,
    104104                "Missing row in the cost matrix"
    105105        );
     
    107107        // GENERATED START, DO NOT EDIT
    108108        // GENERATED BY BasicTypes-gen.cc
    109         static const int signMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
     109        static const int signMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
    110110                /*               B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    111111                /*      B */ {   0,   0,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     
    148148        // GENERATED END
    149149        static_assert(
    150                 sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
     150                sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES,
    151151                "Missing row in the sign matrix"
    152152        );
     
    279279                conversionCostFromBasicToBasic( basicType, dstAsBasic );
    280280        } else if ( dynamic_cast< const ast::EnumAttrType *>(dst) ) {
    281                 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
     281                static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
    282282                cost = costCalc( basicType, integer, srcIsLvalue, symtab, env );
    283283        } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
     
    369369                        }
    370370                }
    371         }
    372         static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
     371                return;
     372        }
     373        static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
    373374        cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
    374375        if ( cost < Cost::unsafe ) {
     
    395396                    if ( cost < Cost::unsafe ) cost.incSafe();
    396397            } else {
    397                     static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
     398                    static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
    398399                    cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
    399400                    if ( cost < Cost::unsafe ) {
     
    460461        } else if ( const ast::BasicType * dstAsBasic =
    461462                        dynamic_cast< const ast::BasicType * >( dst ) ) {
    462                 int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
     463                int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ];
    463464                if ( -1 == tableResult ) {
    464465                        cost = Cost::unsafe;
     
    466467                        cost = Cost::zero;
    467468                        cost.incSafe( tableResult + 1 );
    468                         cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
     469                        cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] );
    469470                }
    470471                // this has the effect of letting any expr such as x+0, x+1 to be typed
     
    492493        } else if ( const ast::BasicType * dstAsBasic =
    493494                        dynamic_cast< const ast::BasicType * >( dst ) ) {
    494                 int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
     495                int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ];
    495496                if ( -1 == tableResult ) {
    496497                        cost = Cost::unsafe;
     
    498499                        cost = Cost::zero;
    499500                        cost.incSafe( tableResult + 1 );
    500                         cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
     501                        cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] );
    501502                }
    502503        } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
  • TabularUnified src/ResolvExpr/PtrsCastable.cc

    r748c751 r38093ae  
    100100                                result = 1;
    101101                        } else if ( auto bt = dynamic_cast< const ast::BasicType * >( dst ) ) {
    102                                 if ( bt->kind == ast::BasicType::SignedInt ) {
     102                                if ( bt->kind == ast::BasicKind::SignedInt ) {
    103103                                        result = 0;
    104104                                } else {
  • TabularUnified src/ResolvExpr/ResolveTypeof.cc

    r748c751 r38093ae  
    6363                        if ( newType.as< ast::EnumInstType >() ) {
    6464                                newType = new ast::BasicType(
    65                                         ast::BasicType::SignedInt, newType->qualifiers, copy(newType->attributes) );
     65                                        ast::BasicKind::SignedInt, newType->qualifiers, copy(newType->attributes) );
    6666                        }
    6767                        reset_qualifiers(
     
    9191                auto mutType = mutate(arrayType);
    9292                auto globalSizeType = context.global.sizeType;
    93                 ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType(ast::BasicType::LongUnsignedInt);
     93                ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType( ast::BasicKind::LongUnsignedInt );
    9494                mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, context );
    9595
  • TabularUnified src/ResolvExpr/Resolver.cc

    r748c751 r38093ae  
    351351        bool isCharType( const ast::Type * t ) {
    352352                if ( auto bt = dynamic_cast< const ast::BasicType * >( t ) ) {
    353                         return bt->kind == ast::BasicType::Char
    354                                 || bt->kind == ast::BasicType::SignedChar
    355                                 || bt->kind == ast::BasicType::UnsignedChar;
     353                        return bt->kind == ast::BasicKind::Char
     354                                || bt->kind == ast::BasicKind::SignedChar
     355                                || bt->kind == ast::BasicKind::UnsignedChar;
    356356                }
    357357                return false;
     
    458458                        if (attr->params.size() == 1) {
    459459                                auto arg = attr->params.front();
    460                                 auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::BasicType::LongLongSignedInt ), context );
     460                                auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::BasicKind::LongLongSignedInt ), context );
    461461                                auto result = eval(arg);
    462462
     
    624624                        objectDecl = fixObjectType( objectDecl, context );
    625625                        currentObject = ast::CurrentObject{
    626                                 objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } };
     626                                objectDecl->location, new ast::BasicType{ ast::BasicKind::SignedInt } };
    627627                }
    628628        } else {
     
    10951095                // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally
    10961096                ast::ptr< ast::Type > target =
    1097                         new ast::BasicType{ ast::BasicType::LongLongUnsignedInt };
     1097                        new ast::BasicType{ ast::BasicKind::LongLongUnsignedInt };
    10981098                auto timeout_time = findSingleExpression( stmt->timeout_time, target, context );
    10991099                auto timeout_cond = findCondExpression( stmt->timeout_cond, context );
Note: See TracChangeset for help on using the changeset viewer.