Changeset e67a82d for src/ResolvExpr/SatisfyAssertions.cpp
- Timestamp:
- Aug 20, 2020, 11:48:15 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d685cb0
- Parents:
- 67ca73e (diff), 013b028 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/SatisfyAssertions.cpp
r67ca73e re67a82d 9 9 // Author : Aaron B. Moss 10 10 // Created On : Mon Jun 10 17:45:00 2019 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Mon Jun 10 17:45:00 201913 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Oct 1 13:56:00 2019 13 // Update Count : 2 14 14 // 15 15 … … 188 188 189 189 matches.emplace_back( 190 cdata, adjType, std::move( newEnv ), std::move( newNeed ), std::move( have ),190 cdata, adjType, std::move( newEnv ), std::move( have ), std::move( newNeed ), 191 191 std::move( newOpen ), crntResnSlot ); 192 192 } … … 229 229 InferMatcher( InferCache & inferred ) : inferred( inferred ) {} 230 230 231 const ast::Expr * post mutate( const ast::Expr * expr ) {231 const ast::Expr * postvisit( const ast::Expr * expr ) { 232 232 // Skip if no slots to find 233 if ( expr->inferred.mode != ast::Expr::InferUnion::Slots ) return expr; 234 233 if ( !expr->inferred.hasSlots() ) return expr; 234 // if ( expr->inferred.mode != ast::Expr::InferUnion::Slots ) return expr; 235 std::vector<UniqueId> missingSlots; 235 236 // find inferred parameters for resolution slots 236 ast::InferredParams newInferred;237 ast::InferredParams * newInferred = new ast::InferredParams(); 237 238 for ( UniqueId slot : expr->inferred.resnSlots() ) { 238 239 // fail if no matching assertions found 239 240 auto it = inferred.find( slot ); 240 241 if ( it == inferred.end() ) { 241 assert(!"missing assertion"); 242 std::cerr << "missing assertion " << slot << std::endl; 243 missingSlots.push_back(slot); 244 continue; 242 245 } 243 246 … … 245 248 for ( auto & entry : it->second ) { 246 249 // recurse on inferParams of resolved expressions 247 entry.second.expr = post mutate( entry.second.expr );248 auto res = newInferred .emplace( entry );250 entry.second.expr = postvisit( entry.second.expr ); 251 auto res = newInferred->emplace( entry ); 249 252 assert( res.second && "all assertions newly placed" ); 250 253 } … … 252 255 253 256 ast::Expr * ret = mutate( expr ); 254 ret->inferred.set_inferParams( std::move( newInferred ) ); 257 ret->inferred.set_inferParams( newInferred ); 258 if (!missingSlots.empty()) ret->inferred.resnSlots() = missingSlots; 255 259 return ret; 256 260 } … … 299 303 Cost cost; 300 304 301 OutType( 302 const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 305 OutType( 306 const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 303 307 const std::vector< DeferRef > & as, const ast::SymbolTable & symtab ) 304 308 : env( e ), open( o ), assns( as ), cost( Cost::zero ) { … … 306 310 for ( const DeferRef & assn : assns ) { 307 311 // compute conversion cost from satisfying decl to assertion 308 cost += computeConversionCost( 309 assn.match.adjType, assn.decl->get_type(), symtab, env );310 312 cost += computeConversionCost( 313 assn.match.adjType, assn.decl->get_type(), false, symtab, env ); 314 311 315 // mark vars+specialization on function-type assertions 312 const ast::FunctionType * func = 316 const ast::FunctionType * func = 313 317 GenPoly::getFunctionType( assn.match.cdata.id->get_type() ); 314 318 if ( ! func ) continue; … … 317 321 cost.decSpec( specCost( param->get_type() ) ); 318 322 } 319 323 320 324 cost.incVar( func->forall.size() ); 321 325 322 326 for ( const ast::TypeDecl * td : func->forall ) { 323 327 cost.decSpec( td->assertions.size() ); … … 329 333 }; 330 334 331 CandidateEnvMerger( 332 const ast::TypeEnvironment & env, const ast::OpenVarSet & open, 335 CandidateEnvMerger( 336 const ast::TypeEnvironment & env, const ast::OpenVarSet & open, 333 337 const ast::SymbolTable & syms ) 334 338 : crnt(), envs{ env }, opens{ open }, symtab( syms ) {}
Note:
See TracChangeset
for help on using the changeset viewer.