@@ -229,14 +229,22 @@ struct RequirementMachine::Implementation {
229
229
RewriteContext Context;
230
230
RewriteSystem System;
231
231
EquivalenceClassMap Map;
232
+ CanGenericSignature Sig;
232
233
bool Complete = false ;
233
234
234
235
explicit Implementation (ASTContext &ctx)
235
236
: Context(ctx),
236
237
System(Context),
237
238
Map(Context, System.getProtocols()) {}
239
+ void dump (llvm::raw_ostream &out);
238
240
};
239
241
242
+ void RequirementMachine::Implementation::dump (llvm::raw_ostream &out) {
243
+ out << " Requirement machine for " << Sig << " \n " ;
244
+ System.dump (out);
245
+ Map.dump (out);
246
+ }
247
+
240
248
RequirementMachine::RequirementMachine (ASTContext &ctx) : Context(ctx) {
241
249
Impl = new Implementation (ctx);
242
250
}
@@ -246,6 +254,8 @@ RequirementMachine::~RequirementMachine() {
246
254
}
247
255
248
256
void RequirementMachine::addGenericSignature (CanGenericSignature sig) {
257
+ Impl->Sig = sig;
258
+
249
259
PrettyStackTraceGenericSignature debugStack (" building rewrite system for" , sig);
250
260
251
261
auto *Stats = Context.Stats ;
@@ -270,7 +280,7 @@ void RequirementMachine::addGenericSignature(CanGenericSignature sig) {
270
280
Impl->System .initialize (std::move (builder.Rules ),
271
281
std::move (builder.Protocols ));
272
282
273
- computeCompletion (sig );
283
+ computeCompletion ();
274
284
275
285
if (Context.LangOpts .DebugRequirementMachine ) {
276
286
llvm::dbgs () << " }\n " ;
@@ -279,7 +289,7 @@ void RequirementMachine::addGenericSignature(CanGenericSignature sig) {
279
289
280
290
// / Attempt to obtain a confluent rewrite system using the completion
281
291
// / procedure.
282
- void RequirementMachine::computeCompletion (CanGenericSignature sig ) {
292
+ void RequirementMachine::computeCompletion () {
283
293
while (true ) {
284
294
// First, run the Knuth-Bendix algorithm to resolve overlapping rules.
285
295
auto result = Impl->System .computeConfluentCompletion (
@@ -298,13 +308,13 @@ void RequirementMachine::computeCompletion(CanGenericSignature sig) {
298
308
break ;
299
309
300
310
case RewriteSystem::CompletionResult::MaxIterations:
301
- llvm::errs () << " Generic signature " << sig
311
+ llvm::errs () << " Generic signature " << Impl-> Sig
302
312
<< " exceeds maximum completion step count\n " ;
303
313
Impl->System .dump (llvm::errs ());
304
314
abort ();
305
315
306
316
case RewriteSystem::CompletionResult::MaxDepth:
307
- llvm::errs () << " Generic signature " << sig
317
+ llvm::errs () << " Generic signature " << Impl-> Sig
308
318
<< " exceeds maximum completion depth\n " ;
309
319
Impl->System .dump (llvm::errs ());
310
320
abort ();
@@ -351,8 +361,7 @@ bool RequirementMachine::isComplete() const {
351
361
}
352
362
353
363
void RequirementMachine::dump (llvm::raw_ostream &out) const {
354
- Impl->System .dump (out);
355
- Impl->Map .dump (out);
364
+ Impl->dump (out);
356
365
}
357
366
358
367
bool RequirementMachine::requiresClass (Type depType) const {
@@ -450,4 +459,4 @@ bool RequirementMachine::areSameTypeParameterInContext(Type depType1,
450
459
Impl->System .simplify (term2);
451
460
452
461
return (term1 == term2);
453
- }
462
+ }
0 commit comments