Changeset 4ee1efb for src/ResolvExpr


Ignore:
Timestamp:
Oct 26, 2017, 11:23:26 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
136ccd7
Parents:
0b9be4d (diff), 598f50e (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.
git-author:
Rob Schluntz <rschlunt@…> (10/26/17 10:43:08)
git-committer:
Rob Schluntz <rschlunt@…> (10/26/17 11:23:26)
Message:

Merge branch 'fix-missing-cast-warning' into cleanup-dtors

Location:
src/ResolvExpr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AdjustExprType.cc

    r0b9be4d r4ee1efb  
    2828                void premutate( BasicType * ) { visit_children = false; }
    2929                void premutate( PointerType * ) { visit_children = false; }
     30                void premutate( ArrayType * ) { visit_children = false; }
    3031                void premutate( FunctionType * ) { visit_children = false; }
    3132                void premutate( StructInstType * ) { visit_children = false; }
     
    5960
    6061        Type * AdjustExprType::postmutate( ArrayType * arrayType ) {
    61                 // need to recursively mutate the base type in order for multi-dimensional arrays to work.
    6262                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base );
    6363                arrayType->base = nullptr;
  • src/ResolvExpr/AlternativeFinder.cc

    r0b9be4d r4ee1efb  
    180180                        throw SemanticError( "No reasonable alternatives for expression ", expr );
    181181                }
    182                 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    183                         if ( adjust ) {
    184                                 adjustExprType( i->expr->get_result(), i->env, indexer );
    185                         }
    186                 }
    187182                if ( prune ) {
    188183                        PRINT(
     
    206201                                std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl;
    207202                        )
     203                }
     204                // adjust types after pruning so that types substituted by pruneAlternatives are correctly adjusted
     205                for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
     206                        if ( adjust ) {
     207                                adjustExprType( i->expr->get_result(), i->env, indexer );
     208                        }
    208209                }
    209210
     
    318319        Cost computeExpressionConversionCost( Expression *& actualExpr, Type * formalType, const SymTab::Indexer &indexer, const TypeEnvironment & env ) {
    319320                Cost convCost = computeConversionCost( actualExpr->result, formalType, indexer, env );
    320                 // if ( convCost != Cost::zero ) {
    321 
    322                 // xxx - temporary -- ignore poly cost, since this causes some polymorphic functions to be cast, which causes the specialize
    323                 // pass to try to specialize them, which currently does not work. Once that is fixed, remove the next 3 lines and uncomment the
    324                 // previous line.
     321
     322                // if there is a non-zero conversion cost, ignoring poly cost, then the expression requires conversion.
     323                // ignore poly cost for now, since this requires resolution of the cast to infer parameters and this
     324                // does not currently work for the reason stated below.
    325325                Cost tmpCost = convCost;
    326326                tmpCost.incPoly( -tmpCost.get_polyCost() );
    327327                if ( tmpCost != Cost::zero ) {
     328                // if ( convCost != Cost::zero ) {
    328329                        Type *newType = formalType->clone();
    329330                        env.apply( newType );
     
    631632                                        std::cerr << std::endl;
    632633                                )
    633                                 ApplicationExpr *appExpr = static_cast< ApplicationExpr* >( newerAlt.expr );
    634634                                // follow the current assertion's ID chain to find the correct set of inferred parameters to add the candidate to (i.e. the set of inferred parameters belonging to the entity which requested the assertion parameter).
    635                                 InferredParams * inferParameters = &appExpr->get_inferParams();
     635                                InferredParams * inferParameters = &newerAlt.expr->get_inferParams();
    636636                                for ( UniqueId id : cur->second.idChain ) {
    637637                                        inferParameters = (*inferParameters)[ id ].inferParams.get();
     
    680680                OpenVarSet openVars;
    681681                AssertionSet resultNeed, resultHave;
    682                 TypeEnvironment resultEnv;
     682                TypeEnvironment resultEnv( func.env );
    683683                makeUnifiableVars( funcType, openVars, resultNeed );
    684684                resultEnv.add( funcType->get_forall() ); // add all type variables as open variables now so that those not used in the parameter list are still considered open
     
    914914                                thisCost.incSafe( discardedValues );
    915915                                Alternative newAlt( restructureCast( i->expr->clone(), toType ), i->env, i->cost, thisCost );
    916                                 // xxx - this doesn't work at the moment, since inferParameters requires an ApplicationExpr as the alternative.
    917                                 // Once this works, it should be possible to infer parameters on a cast expression and specialize any function.
    918 
    919                                 // inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    920                                 candidates.emplace_back( std::move( newAlt ) );
     916                                inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    921917                        } // if
    922918                } // for
     
    12971293                                        // count one safe conversion for each value that is thrown away
    12981294                                        thisCost.incSafe( discardedValues );
    1299                                         candidates.push_back( Alternative( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost ) );
     1295                                        Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
     1296                                        inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    13001297                                }
    13011298                        }
  • src/ResolvExpr/Resolver.cc

    r0b9be4d r4ee1efb  
    593593                initExpr->expr = nullptr;
    594594                std::swap( initExpr->env, newExpr->env );
     595                std::swap( initExpr->inferParams, newExpr->inferParams ) ;
    595596                delete initExpr;
    596597
  • src/ResolvExpr/Unify.cc

    r0b9be4d r4ee1efb  
    1717#include <iterator>               // for back_insert_iterator, back_inserter
    1818#include <map>                    // for _Rb_tree_const_iterator, _Rb_tree_i...
    19 #include <memory>                 // for unique_ptr, auto_ptr
     19#include <memory>                 // for unique_ptr
    2020#include <set>                    // for set
    2121#include <string>                 // for string, operator==, operator!=, bas...
     
    170170                                Type *common = 0;
    171171                                // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
    172                                 std::auto_ptr< Type > newType( curClass.type->clone() );
     172                                std::unique_ptr< Type > newType( curClass.type->clone() );
    173173                                newType->get_qualifiers() = typeInst->get_qualifiers();
    174174                                if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
     
    459459                if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) {
    460460
    461                         // not positive this is correct in all cases, but it's needed for typedefs
    462                         if ( arrayType->get_isVarLen() || otherArray->get_isVarLen() ) {
    463                                 return;
    464                         }
    465 
    466461                        if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() &&
    467462                                arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) {
Note: See TracChangeset for help on using the changeset viewer.