@@ -107,7 +107,7 @@ static void recordRelation(Term key,
107
107
108
108
MutableTerm rhs (key);
109
109
110
- inducedRules. emplace_back (lhs, rhs, path);
110
+ ( void ) system. addRule (lhs, rhs, & path);
111
111
}
112
112
113
113
static void recordConflict (Term key,
@@ -140,18 +140,20 @@ namespace {
140
140
ArrayRef<Term> lhsSubstitutions;
141
141
ArrayRef<Term> rhsSubstitutions;
142
142
RewriteContext &ctx;
143
+ RewriteSystem &system;
143
144
SmallVectorImpl<InducedRule> &inducedRules;
144
145
bool debug;
145
146
146
147
public:
147
148
ConcreteTypeMatcher (ArrayRef<Term> lhsSubstitutions,
148
149
ArrayRef<Term> rhsSubstitutions,
149
- RewriteContext &ctx ,
150
+ RewriteSystem &system ,
150
151
SmallVectorImpl<InducedRule> &inducedRules,
151
152
bool debug)
152
153
: lhsSubstitutions(lhsSubstitutions),
153
154
rhsSubstitutions (rhsSubstitutions),
154
- ctx(ctx), inducedRules(inducedRules), debug(debug) {}
155
+ ctx(system.getRewriteContext()), system(system),
156
+ inducedRules(inducedRules), debug(debug) {}
155
157
156
158
bool alwaysMismatchTypeParameters () const { return true ; }
157
159
@@ -171,7 +173,9 @@ namespace {
171
173
llvm::dbgs () << " %% Induced rule " << lhsTerm
172
174
<< " == " << rhsTerm << " \n " ;
173
175
}
174
- inducedRules.emplace_back (lhsTerm, rhsTerm);
176
+
177
+ // FIXME: Need a rewrite path here.
178
+ (void ) system.addRule (lhsTerm, rhsTerm);
175
179
}
176
180
return true ;
177
181
}
@@ -193,7 +197,9 @@ namespace {
193
197
llvm::dbgs () << " %% Induced rule " << subjectTerm
194
198
<< " == " << constraintTerm << " \n " ;
195
199
}
196
- inducedRules.emplace_back (subjectTerm, constraintTerm);
200
+
201
+ // FIXME: Need a rewrite path here.
202
+ (void ) system.addRule (subjectTerm, constraintTerm);
197
203
return true ;
198
204
}
199
205
@@ -214,7 +220,9 @@ namespace {
214
220
llvm::dbgs () << " %% Induced rule " << subjectTerm
215
221
<< " == " << constraintTerm << " \n " ;
216
222
}
217
- inducedRules.emplace_back (subjectTerm, constraintTerm);
223
+
224
+ // FIXME: Need a rewrite path here.
225
+ (void ) system.addRule (subjectTerm, constraintTerm);
218
226
return true ;
219
227
}
220
228
@@ -251,7 +259,7 @@ namespace {
251
259
// /
252
260
// / Returns true if a conflict was detected.
253
261
static bool unifyConcreteTypes (
254
- Symbol lhs, Symbol rhs, RewriteContext &ctx ,
262
+ Symbol lhs, Symbol rhs, RewriteSystem &system ,
255
263
SmallVectorImpl<InducedRule> &inducedRules,
256
264
bool debug) {
257
265
auto lhsType = lhs.getConcreteType ();
@@ -263,7 +271,7 @@ static bool unifyConcreteTypes(
263
271
264
272
ConcreteTypeMatcher matcher (lhs.getSubstitutions (),
265
273
rhs.getSubstitutions (),
266
- ctx , inducedRules, debug);
274
+ system , inducedRules, debug);
267
275
if (!matcher.match (lhsType, rhsType)) {
268
276
// FIXME: Diagnose the conflict
269
277
if (debug) {
@@ -299,7 +307,7 @@ static bool unifyConcreteTypes(
299
307
// / Returns the most derived superclass, which becomes the new superclass
300
308
// / that gets recorded in the property map.
301
309
static std::pair<Symbol, bool > unifySuperclasses (
302
- Symbol lhs, Symbol rhs, RewriteContext &ctx ,
310
+ Symbol lhs, Symbol rhs, RewriteSystem &system ,
303
311
SmallVectorImpl<InducedRule> &inducedRules,
304
312
bool debug) {
305
313
if (debug) {
@@ -343,7 +351,7 @@ static std::pair<Symbol, bool> unifySuperclasses(
343
351
// Unify type contructor arguments.
344
352
ConcreteTypeMatcher matcher (lhs.getSubstitutions (),
345
353
rhs.getSubstitutions (),
346
- ctx , inducedRules, debug);
354
+ system , inducedRules, debug);
347
355
if (!matcher.match (lhsType, rhsType)) {
348
356
if (debug) {
349
357
llvm::dbgs () << " %% Superclass conflict\n " ;
@@ -439,8 +447,7 @@ void PropertyMap::addProperty(
439
447
} else {
440
448
assert (props->SuperclassRule .hasValue ());
441
449
auto pair = unifySuperclasses (*props->Superclass , property,
442
- System.getRewriteContext (),
443
- inducedRules, debug);
450
+ System, inducedRules, debug);
444
451
props->Superclass = pair.first ;
445
452
bool conflict = pair.second ;
446
453
if (conflict) {
@@ -459,8 +466,7 @@ void PropertyMap::addProperty(
459
466
} else {
460
467
assert (props->ConcreteTypeRule .hasValue ());
461
468
bool conflict = unifyConcreteTypes (*props->ConcreteType , property,
462
- System.getRewriteContext (),
463
- inducedRules, debug);
469
+ System, inducedRules, debug);
464
470
if (conflict) {
465
471
recordConflict (key, *props->ConcreteTypeRule , ruleID, System);
466
472
return ;
@@ -741,7 +747,8 @@ void PropertyMap::concretizeTypeWitnessInConformance(
741
747
key, requirementKind, concreteType, typeWitness, subjectType,
742
748
substitutions, path);
743
749
744
- inducedRules.emplace_back (constraintType, subjectType, path);
750
+ assert (!path.empty ());
751
+ (void ) System.addRule (constraintType, subjectType, &path);
745
752
if (Debug.contains (DebugFlags::ConcretizeNestedTypes)) {
746
753
llvm::dbgs () << " ^^ Induced rule " << constraintType
747
754
<< " => " << subjectType << " \n " ;
@@ -980,5 +987,5 @@ void PropertyMap::recordConcreteConformanceRule(
980
987
// it to go in the other direction.
981
988
path.invert ();
982
989
983
- inducedRules. emplace_back (std::move (lhs), std::move (rhs), std::move ( path) );
990
+ ( void ) System. addRule (std::move (lhs), std::move (rhs), & path);
984
991
}
0 commit comments