RequirementMachine: Split up list of associated types in ProtocolGraph

Store the protocol's direct associated types separately from the inherited
associated types, since in a couple of places we only need the direct
associated types.

Also, factor out a new ProtocolGraph::compute() method that does all the
steps in the right order.
This commit is contained in:
Slava Pestov
2021-07-12 13:15:49 -04:00
parent 00eca7ee97
commit e36b95d620
5 changed files with 45 additions and 45 deletions

View File

@@ -86,21 +86,21 @@ void RewriteSystemBuilder::addGenericSignature(CanGenericSignature sig) {
// Collect all protocols transitively referenced from the generic signature's
// requirements.
Protocols.visitRequirements(sig->getRequirements());
Protocols.computeTransitiveClosure();
Protocols.computeLinearOrder();
Protocols.computeInheritedProtocols();
Protocols.computeInheritedAssociatedTypes();
Protocols.compute();
// Add rewrite rules for each protocol.
for (auto *proto : Protocols.Protocols) {
for (auto *proto : Protocols.getProtocols()) {
if (Debug) {
llvm::dbgs() << "protocol " << proto->getName() << " {\n";
}
const auto &info = Protocols.getProtocolInfo(proto);
for (auto *type : info.AssociatedTypes)
addAssociatedType(type, proto);
for (auto *assocType : info.AssociatedTypes)
addAssociatedType(assocType, proto);
for (auto *assocType : info.InheritedAssociatedTypes)
addAssociatedType(assocType, proto);
for (auto req : info.Requirements)
addRequirement(req.getCanonical(), proto);