Changeset 22f94a4 for src/ResolvExpr


Ignore:
Timestamp:
Aug 11, 2020, 4:40:15 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0d070ca
Parents:
07d867b (diff), 129674b (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:

Merge branch 'master' into new-ast

Location:
src/ResolvExpr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r07d867b r22f94a4  
    12161216                        unify( castExpr->result, alt.expr->result, alt.env, needAssertions,
    12171217                                haveAssertions, openVars, indexer );
    1218                         Cost thisCost = castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),
    1219                                 indexer, alt.env );
     1218                        Cost thisCost =
     1219                                castExpr->isGenerated
     1220                                ? conversionCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),   indexer, alt.env )
     1221                                : castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(), indexer, alt.env );
    12201222                        PRINT(
    12211223                                std::cerr << "working on cast with result: " << castExpr->result << std::endl;
     
    16981700
    16991701                                // unification run for side-effects
    1700                                 unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
     1702                                bool canUnify = unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
     1703                                (void) canUnify;
    17011704                                // xxx - do some inspecting on this line... why isn't result bound to initAlt.type?
    17021705
    1703                                 Cost thisCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
     1706                                Cost thisCost = computeConversionCost( alt.expr->result, toType, alt.expr->get_lvalue(),
    17041707                                        indexer, newEnv );
     1708
     1709                                PRINT(
     1710                                        Cost legacyCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
     1711                                                indexer, newEnv );
     1712                                        std::cerr << "Considering initialization:";
     1713                                        std::cerr << std::endl << "  FROM: "; alt.expr->result->print(std::cerr);
     1714                                        std::cerr << std::endl << "  TO: ";   toType          ->print(std::cerr);
     1715                                        std::cerr << std::endl << "  Unification " << (canUnify ? "succeeded" : "failed");
     1716                                        std::cerr << std::endl << "  Legacy cost " << legacyCost;
     1717                                        std::cerr << std::endl << "  New cost " << thisCost;
     1718                                        std::cerr << std::endl;
     1719                                )
     1720                               
    17051721                                if ( thisCost != Cost::infinity ) {
    17061722                                        // count one safe conversion for each value that is thrown away
  • src/ResolvExpr/ConversionCost.cc

    r07d867b r22f94a4  
    1010// Created On       : Sun May 17 07:06:19 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Oct  4 14:45:00 2019
     12// Last Modified On : Wed Jul 29 16:11:00 2020
    1313// Update Count     : 28
    1414//
     
    392392        void ConversionCost::postvisit( const FunctionType * ) {}
    393393
    394         void ConversionCost::postvisit( const StructInstType * inst ) {
    395                 /*
    396                 if ( const StructInstType * destAsInst = dynamic_cast< const StructInstType * >( dest ) ) {
    397                         if ( inst->name == destAsInst->name ) {
    398                                 cost = Cost::zero;
    399                         } // if
    400                 } // if
    401                 */
    402         }
    403 
    404         void ConversionCost::postvisit( const UnionInstType * inst ) {
    405                 /*
    406                 if ( const UnionInstType * destAsInst = dynamic_cast< const UnionInstType * >( dest ) ) {
    407                         if ( inst->name == destAsInst->name ) {
    408                                 cost = Cost::zero;
    409                         } // if
    410                 } // if
    411                 */
    412         }
    413 
    414394        void ConversionCost::postvisit( const EnumInstType * ) {
    415395                static Type::Qualifiers q;
     
    685665}
    686666
    687 void ConversionCost_new::postvisit( const ast::StructInstType * structInstType ) {
    688         /*
    689         if ( const ast::StructInstType * dstAsInst =
    690                         dynamic_cast< const ast::StructInstType * >( dst ) ) {
    691                 if ( structInstType->name == dstAsInst->name ) {
    692                         cost = Cost::zero;
    693                 }
    694         }
    695         */
    696 }
    697 
    698 void ConversionCost_new::postvisit( const ast::UnionInstType * unionInstType ) {
    699         /*
    700         if ( const ast::UnionInstType * dstAsInst =
    701                         dynamic_cast< const ast::UnionInstType * >( dst ) ) {
    702                 if ( unionInstType->name == dstAsInst->name ) {
    703                         cost = Cost::zero;
    704                 }
    705         }
    706         */
    707 }
    708 
    709667void ConversionCost_new::postvisit( const ast::EnumInstType * enumInstType ) {
    710668        (void)enumInstType;
  • src/ResolvExpr/ConversionCost.h

    r07d867b r22f94a4  
    1010// Created On       : Sun May 17 09:37:28 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Oct  4 14:59:00 2019
     12// Last Modified On : Wed Jul 29 16:12:00 2020
    1313// Update Count     : 7
    1414//
     
    5151                void postvisit( const ReferenceType * refType );
    5252                void postvisit( const FunctionType * functionType );
    53                 void postvisit( const StructInstType * aggregateUseType );
    54                 void postvisit( const UnionInstType * aggregateUseType );
    5553                void postvisit( const EnumInstType * aggregateUseType );
    5654                void postvisit( const TraitInstType * aggregateUseType );
     
    105103        void postvisit( const ast::ReferenceType * refType );
    106104        void postvisit( const ast::FunctionType * functionType );
    107         void postvisit( const ast::StructInstType * structInstType );
    108         void postvisit( const ast::UnionInstType * unionInstType );
    109105        void postvisit( const ast::EnumInstType * enumInstType );
    110106        void postvisit( const ast::TraitInstType * traitInstType );
Note: See TracChangeset for help on using the changeset viewer.