@@ -50,7 +50,13 @@ enum class CompletionResult {
50
50
MaxRuleLength,
51
51
52
52
// / Maximum concrete type nesting depth exceeded.
53
- MaxConcreteNesting
53
+ MaxConcreteNesting,
54
+
55
+ // / Maximum concrete type size exceeded.
56
+ MaxConcreteSize,
57
+
58
+ // / Maximum type difference count exceeded.
59
+ MaxTypeDifferences,
54
60
};
55
61
56
62
// / A term rewrite system for working with types in a generic signature.
@@ -107,13 +113,16 @@ class RewriteSystem final {
107
113
// / identities among rewrite rules discovered while resolving critical pairs.
108
114
unsigned RecordLoops : 1 ;
109
115
110
- // / The length of the longest initial rule, used for the MaxRuleLength
111
- // / completion non-termination heuristic.
116
+ // / The length of the longest initial rule, for the MaxRuleLength limit.
112
117
unsigned LongestInitialRule : 16 ;
113
118
114
- // / The most deeply nested concrete type appearing in an initial rule, used
115
- // / for the MaxConcreteNesting completion non-termination heuristic.
116
- unsigned DeepestInitialRule : 16 ;
119
+ // / The most deeply nested concrete type appearing in an initial rule,
120
+ // / for the MaxConcreteNesting limit.
121
+ unsigned MaxNestingOfInitialRule : 16 ;
122
+
123
+ // / The largest concrete type by total tree node count that appears in an
124
+ // / initial rule, for the MaxConcreteSize limit.
125
+ unsigned MaxSizeOfInitialRule : 16 ;
117
126
118
127
public:
119
128
explicit RewriteSystem (RewriteContext &ctx);
@@ -143,8 +152,12 @@ class RewriteSystem final {
143
152
return LongestInitialRule;
144
153
}
145
154
146
- unsigned getDeepestInitialRule () const {
147
- return DeepestInitialRule;
155
+ unsigned getMaxNestingOfInitialRule () const {
156
+ return MaxNestingOfInitialRule;
157
+ }
158
+
159
+ unsigned getMaxSizeOfInitialRule () const {
160
+ return MaxSizeOfInitialRule;
148
161
}
149
162
150
163
ArrayRef<const ProtocolDecl *> getProtocols () const {
@@ -206,7 +219,7 @@ class RewriteSystem final {
206
219
// ////////////////////////////////////////////////////////////////////////////
207
220
208
221
// / Pairs of rules which have already been checked for overlap.
209
- llvm::DenseSet<std::pair< unsigned , unsigned >> CheckedOverlaps;
222
+ llvm::DenseSet<std::tuple< unsigned , unsigned , unsigned >> CheckedOverlaps;
210
223
211
224
std::pair<CompletionResult, unsigned >
212
225
performKnuthBendix (unsigned maxRuleCount, unsigned maxRuleLength);
@@ -311,6 +324,10 @@ class RewriteSystem final {
311
324
std::optional<unsigned > &lhsDifferenceID,
312
325
std::optional<unsigned > &rhsDifferenceID);
313
326
327
+ unsigned getTypeDifferenceCount () const {
328
+ return Differences.size ();
329
+ }
330
+
314
331
const TypeDifference &getTypeDifference (unsigned index) const ;
315
332
316
333
void processTypeDifference (const TypeDifference &difference,
0 commit comments