Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/SatisfyAssertions.cpp

    r07d867b rb69233ac  
    99// Author           : Aaron B. Moss
    1010// Created On       : Mon Jun 10 17:45:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Oct  1 13:56:00 2019
    13 // Update Count     : 2
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Mon Jun 10 17:45:00 2019
     13// Update Count     : 1
    1414//
    1515
     
    188188
    189189                                matches.emplace_back(
    190                                         cdata, adjType, std::move( newEnv ), std::move( have ), std::move( newNeed ),
     190                                        cdata, adjType, std::move( newEnv ), std::move( newNeed ), std::move( have ),
    191191                                        std::move( newOpen ), crntResnSlot );
    192192                        }
     
    229229                InferMatcher( InferCache & inferred ) : inferred( inferred ) {}
    230230
    231                 const ast::Expr * postvisit( const ast::Expr * expr ) {
     231                const ast::Expr * postmutate( const ast::Expr * expr ) {
    232232                        // Skip if no slots to find
    233                         if ( !expr->inferred.hasSlots() ) return expr;
    234                         // if ( expr->inferred.mode != ast::Expr::InferUnion::Slots ) return expr;
    235                         std::vector<UniqueId> missingSlots;
     233                        if ( expr->inferred.mode != ast::Expr::InferUnion::Slots ) return expr;
     234
    236235                        // find inferred parameters for resolution slots
    237                         ast::InferredParams * newInferred = new ast::InferredParams();
     236                        ast::InferredParams newInferred;
    238237                        for ( UniqueId slot : expr->inferred.resnSlots() ) {
    239238                                // fail if no matching assertions found
    240239                                auto it = inferred.find( slot );
    241240                                if ( it == inferred.end() ) {
    242                                         std::cerr << "missing assertion " << slot << std::endl;
    243                                         missingSlots.push_back(slot);
    244                                         continue;
     241                                        assert(!"missing assertion");
    245242                                }
    246243
     
    248245                                for ( auto & entry : it->second ) {
    249246                                        // recurse on inferParams of resolved expressions
    250                                         entry.second.expr = postvisit( entry.second.expr );
    251                                         auto res = newInferred->emplace( entry );
     247                                        entry.second.expr = postmutate( entry.second.expr );
     248                                        auto res = newInferred.emplace( entry );
    252249                                        assert( res.second && "all assertions newly placed" );
    253250                                }
     
    255252
    256253                        ast::Expr * ret = mutate( expr );
    257                         ret->inferred.set_inferParams( newInferred );
    258                         if (!missingSlots.empty()) ret->inferred.resnSlots() = missingSlots;
     254                        ret->inferred.set_inferParams( std::move( newInferred ) );
    259255                        return ret;
    260256                }
     
    303299                        Cost cost;
    304300
    305                         OutType(
    306                                 const ast::TypeEnvironment & e, const ast::OpenVarSet & o,
     301                        OutType( 
     302                                const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 
    307303                                const std::vector< DeferRef > & as, const ast::SymbolTable & symtab )
    308304                        : env( e ), open( o ), assns( as ), cost( Cost::zero ) {
     
    310306                                for ( const DeferRef & assn : assns ) {
    311307                                        // compute conversion cost from satisfying decl to assertion
    312                                         cost += computeConversionCost(
    313                                                 assn.match.adjType, assn.decl->get_type(), false, symtab, env );
    314 
     308                                        cost += computeConversionCost( 
     309                                                assn.match.adjType, assn.decl->get_type(), symtab, env );
     310                                       
    315311                                        // mark vars+specialization on function-type assertions
    316                                         const ast::FunctionType * func =
     312                                        const ast::FunctionType * func = 
    317313                                                GenPoly::getFunctionType( assn.match.cdata.id->get_type() );
    318314                                        if ( ! func ) continue;
     
    321317                                                cost.decSpec( specCost( param->get_type() ) );
    322318                                        }
    323 
     319                                       
    324320                                        cost.incVar( func->forall.size() );
    325 
     321                                       
    326322                                        for ( const ast::TypeDecl * td : func->forall ) {
    327323                                                cost.decSpec( td->assertions.size() );
     
    333329                };
    334330
    335                 CandidateEnvMerger(
    336                         const ast::TypeEnvironment & env, const ast::OpenVarSet & open,
     331                CandidateEnvMerger( 
     332                        const ast::TypeEnvironment & env, const ast::OpenVarSet & open, 
    337333                        const ast::SymbolTable & syms )
    338334                : crnt(), envs{ env }, opens{ open }, symtab( syms ) {}
Note: See TracChangeset for help on using the changeset viewer.