Ignore:
Timestamp:
Jan 5, 2017, 3:47:36 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
f831177
Parents:
1e3d5b6
Message:

fix inferred parameter data structures to correctly associate parameters with the entity that requested them, modify tuple specialization and unification to work with self-recursive assertions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r1e3d5b6 r6c3a988f  
    339339                        unifiableVars[ (*tyvar)->get_name() ] = TypeDecl::Data{ *tyvar };
    340340                        for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) {
    341                                 needAssertions[ *assert ] = true;
     341                                needAssertions[ *assert ].isUsed = true;
    342342                        }
    343343///     needAssertions.insert( needAssertions.end(), (*tyvar)->get_assertions().begin(), (*tyvar)->get_assertions().end() );
     
    380380                        }
    381381                        *out++ = arg;
    382                         return true;
    383382                } else if ( actualIt != actualEnd ) {
    384383                        // both actualType and formalType are atomic (non-tuple) types - if they unify
     
    467466        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
    468467                for ( AssertionSet::iterator i = assertSet.begin(); i != assertSet.end(); ++i ) {
    469                         if ( i->second == true ) {
     468                        if ( i->second.isUsed ) {
    470469                                i->first->accept( indexer );
    471470                        }
     
    478477                if ( begin == end ) {
    479478                        if ( newNeed.empty() ) {
     479                                PRINT(
     480                                        std::cerr << "all assertions satisfied, output alternative: ";
     481                                        newAlt.print( std::cerr );
     482                                        std::cerr << std::endl;
     483                                );
    480484                                *out++ = newAlt;
    481485                                return;
     
    494498
    495499                ForwardIterator cur = begin++;
    496                 if ( ! cur->second ) {
     500                if ( ! cur->second.isUsed ) {
    497501                        inferRecursive( begin, end, newAlt, openVars, decls, newNeed, /*needParents,*/ level, indexer, out );
    498502                        return; // xxx - should this continue? previously this wasn't here, and it looks like it should be
     
    538542                                assert( (*candidate)->get_uniqueId() );
    539543                                DeclarationWithType *candDecl = static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) );
     544
     545                                // everything with an empty idChain was pulled in by the current assertion.
     546                                // add current assertion's idChain + current assertion's ID so that the correct inferParameters can be found.
     547                                for ( auto & a : newerNeed ) {
     548                                        if ( a.second.idChain.empty() ) {
     549                                                a.second.idChain = cur->second.idChain;
     550                                                a.second.idChain.push_back( curDecl->get_uniqueId() );
     551                                        }
     552                                }
     553
    540554                                //AssertionParentSet newNeedParents( needParents );
    541555                                // skip repeatingly-self-recursive assertion satisfaction
     
    553567                                )
    554568                                ApplicationExpr *appExpr = static_cast< ApplicationExpr* >( newerAlt.expr );
     569                                // 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).
     570                                InferredParams * inferParameters = &appExpr->get_inferParams();
     571                                for ( UniqueId id : cur->second.idChain ) {
     572                                        inferParameters = (*inferParameters)[ id ].inferParams.get();
     573                                }
    555574                                // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    556                                 appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
     575                                (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    557576                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, /*newNeedParents,*/ level, indexer, out );
    558577                        } else {
Note: See TracChangeset for help on using the changeset viewer.