- File:
-
- 1 edited
-
src/ResolvExpr/SatisfyAssertions.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/SatisfyAssertions.cpp
r07d867b rb69233ac 9 9 // Author : Aaron B. Moss 10 10 // Created On : Mon Jun 10 17:45:00 2019 11 // Last Modified By : A ndrew Beach12 // Last Modified On : Tue Oct 1 13:56:00 201913 // Update Count : 211 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 10 17:45:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 188 188 189 189 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 ), 191 191 std::move( newOpen ), crntResnSlot ); 192 192 } … … 229 229 InferMatcher( InferCache & inferred ) : inferred( inferred ) {} 230 230 231 const ast::Expr * post visit( const ast::Expr * expr ) {231 const ast::Expr * postmutate( const ast::Expr * expr ) { 232 232 // 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 236 235 // find inferred parameters for resolution slots 237 ast::InferredParams * newInferred = new ast::InferredParams();236 ast::InferredParams newInferred; 238 237 for ( UniqueId slot : expr->inferred.resnSlots() ) { 239 238 // fail if no matching assertions found 240 239 auto it = inferred.find( slot ); 241 240 if ( it == inferred.end() ) { 242 std::cerr << "missing assertion " << slot << std::endl; 243 missingSlots.push_back(slot); 244 continue; 241 assert(!"missing assertion"); 245 242 } 246 243 … … 248 245 for ( auto & entry : it->second ) { 249 246 // recurse on inferParams of resolved expressions 250 entry.second.expr = post visit( entry.second.expr );251 auto res = newInferred ->emplace( entry );247 entry.second.expr = postmutate( entry.second.expr ); 248 auto res = newInferred.emplace( entry ); 252 249 assert( res.second && "all assertions newly placed" ); 253 250 } … … 255 252 256 253 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 ) ); 259 255 return ret; 260 256 } … … 303 299 Cost cost; 304 300 305 OutType( 306 const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 301 OutType( 302 const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 307 303 const std::vector< DeferRef > & as, const ast::SymbolTable & symtab ) 308 304 : env( e ), open( o ), assns( as ), cost( Cost::zero ) { … … 310 306 for ( const DeferRef & assn : assns ) { 311 307 // 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 315 311 // mark vars+specialization on function-type assertions 316 const ast::FunctionType * func = 312 const ast::FunctionType * func = 317 313 GenPoly::getFunctionType( assn.match.cdata.id->get_type() ); 318 314 if ( ! func ) continue; … … 321 317 cost.decSpec( specCost( param->get_type() ) ); 322 318 } 323 319 324 320 cost.incVar( func->forall.size() ); 325 321 326 322 for ( const ast::TypeDecl * td : func->forall ) { 327 323 cost.decSpec( td->assertions.size() ); … … 333 329 }; 334 330 335 CandidateEnvMerger( 336 const ast::TypeEnvironment & env, const ast::OpenVarSet & open, 331 CandidateEnvMerger( 332 const ast::TypeEnvironment & env, const ast::OpenVarSet & open, 337 333 const ast::SymbolTable & syms ) 338 334 : crnt(), envs{ env }, opens{ open }, symtab( syms ) {}
Note:
See TracChangeset
for help on using the changeset viewer.