Ignore:
Timestamp:
May 30, 2018, 2:04:51 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
6b8643d
Parents:
cdc4d43
git-author:
Aaron Moss <a3moss@…> (05/30/18 13:45:51)
git-committer:
Aaron Moss <a3moss@…> (05/30/18 14:04:51)
Message:

Remove clones from ArgPack? constructors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rcdc4d43 r1ed958c3  
    462462        }
    463463
    464         // /// Map of declaration uniqueIds (intended to be the assertions in an AssertionSet) to their parents and the number of times they've been included
    465         //typedef std::unordered_map< UniqueId, std::unordered_map< UniqueId, unsigned > > AssertionParentSet;
    466 
    467464        static const int recursionLimit = /*10*/ 4;  ///< Limit to depth of recursion satisfaction
    468         //static const unsigned recursionParentLimit = 1;  ///< Limit to the number of times an assertion can recursively use itself
    469465
    470466        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     
    477473
    478474        template< typename ForwardIterator, typename OutputIterator >
    479         void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, /*const AssertionParentSet &needParents,*/
    480                                                  int level, const SymTab::Indexer &indexer, OutputIterator out ) {
     475        void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, int level, const SymTab::Indexer &indexer, OutputIterator out ) {
    481476                if ( begin == end ) {
    482477                        if ( newNeed.empty() ) {
     
    496491                                        printAssertionSet( newNeed, std::cerr, 8 );
    497492                                )
    498                                 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, /*needParents,*/ level+1, indexer, out );
     493                                inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );
    499494                                return;
    500495                        }
     
    503498                ForwardIterator cur = begin++;
    504499                if ( ! cur->second.isUsed ) {
    505                         inferRecursive( begin, end, newAlt, openVars, decls, newNeed, /*needParents,*/ level, indexer, out );
     500                        inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );
    506501                        return; // xxx - should this continue? previously this wasn't here, and it looks like it should be
    507502                }
     
    556551                                }
    557552
    558                                 //AssertionParentSet newNeedParents( needParents );
    559                                 // skip repeatingly-self-recursive assertion satisfaction
    560                                 // DOESN'T WORK: grandchild nodes conflict with their cousins
    561                                 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
    562 
    563553                                Expression *varExpr = data.combine( newerAlt.cvtCost );
    564554                                varExpr->set_result( adjType->clone() );
     
    575565                                        inferParameters = (*inferParameters)[ id ].inferParams.get();
    576566                                }
    577                                 // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
     567                               
    578568                                (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    579                                 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, /*newNeedParents,*/ level, indexer, out );
     569                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
    580570                        }
    581571                }
     
    597587                addToIndexer( have, decls );
    598588                AssertionSet newNeed;
    599                 //AssertionParentSet needParents;
    600589                PRINT(
    601590                        std::cerr << "env is: " << std::endl;
     
    604593                )
    605594
    606                 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, /*needParents,*/ 0, indexer, out );
     595                inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
    607596//      PRINT(
    608597//          std::cerr << "declaration 14 is ";
     
    637626
    638627                ArgPack()
    639                         : parent(0), expr(), cost(Cost::zero), env(), need(), have(), openVars(), nextArg(0),
    640                           tupleStart(0), nextExpl(0), explAlt(0) {}
     628                        : parent(0), expr(nullptr), cost(Cost::zero), env(), need(), have(), openVars(),
     629                          nextArg(0), tupleStart(0), nextExpl(0), explAlt(0) {}
    641630
    642631                ArgPack(const TypeEnvironment& env, const AssertionSet& need, const AssertionSet& have,
    643632                                const OpenVarSet& openVars)
    644                         : parent(0), expr(), cost(Cost::zero), env(env), need(need), have(have),
     633                        : parent(0), expr(nullptr), cost(Cost::zero), env(env), need(need), have(have),
    645634                          openVars(openVars), nextArg(0), tupleStart(0), nextExpl(0), explAlt(0) {}
    646635
     
    649638                                unsigned tupleStart = 0, Cost cost = Cost::zero, unsigned nextExpl = 0,
    650639                                unsigned explAlt = 0 )
    651                         : parent(parent), expr(expr->clone()), cost(cost), env(move(env)), need(move(need)),
     640                        : parent(parent), expr(expr), cost(cost), env(move(env)), need(move(need)),
    652641                          have(move(have)), openVars(move(openVars)), nextArg(nextArg), tupleStart(tupleStart),
    653642                          nextExpl(nextExpl), explAlt(explAlt) {}
     
    655644                ArgPack(const ArgPack& o, TypeEnvironment&& env, AssertionSet&& need, AssertionSet&& have,
    656645                                OpenVarSet&& openVars, unsigned nextArg, Cost added )
    657                         : parent(o.parent), expr(o.expr ? o.expr->clone() : nullptr), cost(o.cost + added),
    658                           env(move(env)), need(move(need)), have(move(have)), openVars(move(openVars)),
    659                           nextArg(nextArg), tupleStart(o.tupleStart), nextExpl(0), explAlt(0) {}
     646                        : parent(o.parent), expr(o.expr), cost(o.cost + added), env(move(env)),
     647                          need(move(need)), have(move(have)), openVars(move(openVars)), nextArg(nextArg),
     648                          tupleStart(o.tupleStart), nextExpl(0), explAlt(0) {}
    660649
    661650                /// true iff this pack is in the middle of an exploded argument
Note: See TracChangeset for help on using the changeset viewer.