Ignore:
Timestamp:
Jul 19, 2019, 2:16:01 PM (6 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:
4eb43fa
Parents:
1f1c102 (diff), 8ac3b0e (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ResolveAssertions.cc

    r1f1c102 rf53acdf8  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri Oct 05 13:46:00 2018
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Fri Oct 05 13:46:00 2018
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jul 10 16:10:37 2019
     13// Update Count     : 2
    1414//
    1515
     
    197197                        }
    198198                        if ( i == b.size() /* && i < a.size() */ ) return 1;
    199                        
     199
    200200                        int c = a[i].compare( b[i] );
    201201                        if ( c != 0 ) return c;
     
    220220
    221221                /// Initial resolution state for an alternative
    222                 ResnState( Alternative& a, SymTab::Indexer& indexer )
     222                ResnState( Alternative & a, SymTab::Indexer & indexer )
    223223                : alt(a), need(), newNeed(), deferred(), inferred(), costs{ Cost::zero }, indexer(indexer) {
    224224                        need.swap( a.need );
     
    226226
    227227                /// Updated resolution state with new need-list
    228                 ResnState( ResnState&& o, IterateFlag )
     228                ResnState( ResnState && o, IterateFlag )
    229229                : alt(std::move(o.alt)), need(o.newNeed.begin(), o.newNeed.end()), newNeed(), deferred(),
    230230                  inferred(std::move(o.inferred)), costs(o.costs), indexer(o.indexer) {
     
    234234
    235235        /// Binds a single assertion, updating resolution state
    236         void bindAssertion( const DeclarationWithType* decl, AssertionSetValue info, Alternative& alt,
    237                         AssnCandidate& match, InferCache& inferred ) {
    238 
    239                 DeclarationWithType* candidate = match.cdata.id;
    240                 assertf( candidate->get_uniqueId(), "Assertion candidate does not have a unique ID: %s", toString( candidate ).c_str() );
    241 
    242                 Expression* varExpr = match.cdata.combine( alt.cvtCost );
     236        void bindAssertion( const DeclarationWithType * decl, AssertionSetValue info, Alternative & alt,
     237                        AssnCandidate & match, InferCache & inferred ) {
     238
     239                const DeclarationWithType * candidate = match.cdata.id;
     240                assertf( candidate->uniqueId, "Assertion candidate does not have a unique ID: %s", toString( candidate ).c_str() );
     241
     242                Expression * varExpr = match.cdata.combine( alt.cvtCost );
    243243                delete varExpr->result;
    244244                varExpr->result = match.adjType->clone();
     
    247247                // place newly-inferred assertion in proper place in cache
    248248                inferred[ info.resnSlot ][ decl->get_uniqueId() ] = ParamEntry{
    249                                 candidate->get_uniqueId(), candidate->clone(), match.adjType->clone(), decl->get_type()->clone(),
     249                                candidate->uniqueId, candidate->clone(), match.adjType->clone(), decl->get_type()->clone(),
    250250                                varExpr };
    251251        }
    252252
    253253        /// Adds a captured assertion to the symbol table
    254         void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     254        void addToIndexer( AssertionSet & assertSet, SymTab::Indexer & indexer ) {
    255255                for ( auto&  i : assertSet ) {
    256256                        if ( i.second.isUsed ) {
     
    264264
    265265        /// Resolve a single assertion, in context
    266         bool resolveAssertion( AssertionItem& assn, ResnState& resn ) {
     266        bool resolveAssertion( AssertionItem & assn, ResnState & resn ) {
    267267                // skip unused assertions
    268268                if ( ! assn.info.isUsed ) return true;
     
    274274                // find the candidates that unify with the desired type
    275275                CandidateList matches;
    276                 for ( const auto& cdata : candidates ) {
    277                         DeclarationWithType* candidate = cdata.id;
     276                for ( const auto & cdata : candidates ) {
     277                        const DeclarationWithType * candidate = cdata.id;
    278278
    279279                        // build independent unification context for candidate
     
    281281                        TypeEnvironment newEnv{ resn.alt.env };
    282282                        OpenVarSet newOpenVars{ resn.alt.openVars };
    283                         Type* adjType = candidate->get_type()->clone();
     283                        Type * adjType = candidate->get_type()->clone();
    284284                        adjustExprType( adjType, newEnv, resn.indexer );
    285285                        renameTyVars( adjType );
     
    368368                std::string resKey = SymTab::Mangler::mangleType( resType );
    369369                delete resType;
    370                 return std::move( resKey );
    371         }
    372        
    373         /// Replace resnSlots with inferParams and add alternative to output list, if meets pruning 
     370                return resKey;
     371        }
     372
     373        /// Replace resnSlots with inferParams and add alternative to output list, if meets pruning
    374374        /// threshold.
    375375        void finalizeAssertions( ResnState& resn, PruneMap & pruneThresholds, AltList& out ) {
     
    406406                ResnList resns{ ResnState{ alt, root_indexer } };
    407407                ResnList new_resns{};
    408                
     408
    409409                // Pruning thresholds by result type of the output alternatives.
    410410                // Alternatives *should* be generated in sorted order, so no need to retroactively prune
Note: See TracChangeset for help on using the changeset viewer.