|
14 | 14 | #define SWIFT_REQUIREMENTMACHINE_H |
15 | 15 |
|
16 | 16 | #include "swift/AST/GenericSignature.h" |
| 17 | +#include "llvm/ADT/DenseMap.h" |
| 18 | +#include <vector> |
| 19 | + |
| 20 | +#include "PropertyMap.h" |
| 21 | +#include "ProtocolGraph.h" |
| 22 | +#include "RewriteContext.h" |
| 23 | +#include "RewriteSystem.h" |
17 | 24 |
|
18 | 25 | namespace llvm { |
19 | 26 | class raw_ostream; |
@@ -81,6 +88,35 @@ class RequirementMachine final { |
81 | 88 | void dump(llvm::raw_ostream &out) const; |
82 | 89 | }; |
83 | 90 |
|
| 91 | +/// We use the PIMPL pattern to avoid creeping header dependencies. |
| 92 | +struct RequirementMachine::Implementation { |
| 93 | + RewriteContext &Context; |
| 94 | + RewriteSystem System; |
| 95 | + PropertyMap Map; |
| 96 | + CanGenericSignature Sig; |
| 97 | + bool Complete = false; |
| 98 | + |
| 99 | + /// All conformance access paths computed so far. |
| 100 | + llvm::DenseMap<std::pair<CanType, ProtocolDecl *>, |
| 101 | + ConformanceAccessPath> ConformanceAccessPaths; |
| 102 | + |
| 103 | + /// Conformance access paths computed during the last round. All elements |
| 104 | + /// have the same length. If a conformance access path of greater length |
| 105 | + /// is requested, we refill CurrentConformanceAccessPaths with all paths of |
| 106 | + /// length N+1, and add them to the ConformanceAccessPaths map. |
| 107 | + std::vector<std::pair<CanType, ConformanceAccessPath>> |
| 108 | + CurrentConformanceAccessPaths; |
| 109 | + |
| 110 | + explicit Implementation(RewriteContext &ctx) |
| 111 | + : Context(ctx), |
| 112 | + System(Context), |
| 113 | + Map(Context, System.getProtocols()) {} |
| 114 | + void verify(const MutableTerm &term); |
| 115 | + void dump(llvm::raw_ostream &out); |
| 116 | + |
| 117 | + MutableTerm getLongestValidPrefix(const MutableTerm &term); |
| 118 | +}; |
| 119 | + |
84 | 120 | } // end namespace rewriting |
85 | 121 |
|
86 | 122 | } // end namespace swift |
|
0 commit comments