@@ -107,7 +107,7 @@ static void recordRelation(Term key,
107107
108108 MutableTerm rhs (key);
109109
110- inducedRules. emplace_back (lhs, rhs, path);
110+ ( void ) system. addRule (lhs, rhs, & path);
111111}
112112
113113static void recordConflict (Term key,
@@ -140,18 +140,20 @@ namespace {
140140 ArrayRef<Term> lhsSubstitutions;
141141 ArrayRef<Term> rhsSubstitutions;
142142 RewriteContext &ctx;
143+ RewriteSystem &system;
143144 SmallVectorImpl<InducedRule> &inducedRules;
144145 bool debug;
145146
146147 public:
147148 ConcreteTypeMatcher (ArrayRef<Term> lhsSubstitutions,
148149 ArrayRef<Term> rhsSubstitutions,
149- RewriteContext &ctx ,
150+ RewriteSystem &system ,
150151 SmallVectorImpl<InducedRule> &inducedRules,
151152 bool debug)
152153 : lhsSubstitutions(lhsSubstitutions),
153154 rhsSubstitutions (rhsSubstitutions),
154- ctx(ctx), inducedRules(inducedRules), debug(debug) {}
155+ ctx(system.getRewriteContext()), system(system),
156+ inducedRules(inducedRules), debug(debug) {}
155157
156158 bool alwaysMismatchTypeParameters () const { return true ; }
157159
@@ -171,7 +173,9 @@ namespace {
171173 llvm::dbgs () << " %% Induced rule " << lhsTerm
172174 << " == " << rhsTerm << " \n " ;
173175 }
174- inducedRules.emplace_back (lhsTerm, rhsTerm);
176+
177+ // FIXME: Need a rewrite path here.
178+ (void ) system.addRule (lhsTerm, rhsTerm);
175179 }
176180 return true ;
177181 }
@@ -193,7 +197,9 @@ namespace {
193197 llvm::dbgs () << " %% Induced rule " << subjectTerm
194198 << " == " << constraintTerm << " \n " ;
195199 }
196- inducedRules.emplace_back (subjectTerm, constraintTerm);
200+
201+ // FIXME: Need a rewrite path here.
202+ (void ) system.addRule (subjectTerm, constraintTerm);
197203 return true ;
198204 }
199205
@@ -214,7 +220,9 @@ namespace {
214220 llvm::dbgs () << " %% Induced rule " << subjectTerm
215221 << " == " << constraintTerm << " \n " ;
216222 }
217- inducedRules.emplace_back (subjectTerm, constraintTerm);
223+
224+ // FIXME: Need a rewrite path here.
225+ (void ) system.addRule (subjectTerm, constraintTerm);
218226 return true ;
219227 }
220228
@@ -251,7 +259,7 @@ namespace {
251259// /
252260// / Returns true if a conflict was detected.
253261static bool unifyConcreteTypes (
254- Symbol lhs, Symbol rhs, RewriteContext &ctx ,
262+ Symbol lhs, Symbol rhs, RewriteSystem &system ,
255263 SmallVectorImpl<InducedRule> &inducedRules,
256264 bool debug) {
257265 auto lhsType = lhs.getConcreteType ();
@@ -263,7 +271,7 @@ static bool unifyConcreteTypes(
263271
264272 ConcreteTypeMatcher matcher (lhs.getSubstitutions (),
265273 rhs.getSubstitutions (),
266- ctx , inducedRules, debug);
274+ system , inducedRules, debug);
267275 if (!matcher.match (lhsType, rhsType)) {
268276 // FIXME: Diagnose the conflict
269277 if (debug) {
@@ -299,7 +307,7 @@ static bool unifyConcreteTypes(
299307// / Returns the most derived superclass, which becomes the new superclass
300308// / that gets recorded in the property map.
301309static std::pair<Symbol, bool > unifySuperclasses (
302- Symbol lhs, Symbol rhs, RewriteContext &ctx ,
310+ Symbol lhs, Symbol rhs, RewriteSystem &system ,
303311 SmallVectorImpl<InducedRule> &inducedRules,
304312 bool debug) {
305313 if (debug) {
@@ -343,7 +351,7 @@ static std::pair<Symbol, bool> unifySuperclasses(
343351 // Unify type contructor arguments.
344352 ConcreteTypeMatcher matcher (lhs.getSubstitutions (),
345353 rhs.getSubstitutions (),
346- ctx , inducedRules, debug);
354+ system , inducedRules, debug);
347355 if (!matcher.match (lhsType, rhsType)) {
348356 if (debug) {
349357 llvm::dbgs () << " %% Superclass conflict\n " ;
@@ -439,8 +447,7 @@ void PropertyMap::addProperty(
439447 } else {
440448 assert (props->SuperclassRule .hasValue ());
441449 auto pair = unifySuperclasses (*props->Superclass , property,
442- System.getRewriteContext (),
443- inducedRules, debug);
450+ System, inducedRules, debug);
444451 props->Superclass = pair.first ;
445452 bool conflict = pair.second ;
446453 if (conflict) {
@@ -459,8 +466,7 @@ void PropertyMap::addProperty(
459466 } else {
460467 assert (props->ConcreteTypeRule .hasValue ());
461468 bool conflict = unifyConcreteTypes (*props->ConcreteType , property,
462- System.getRewriteContext (),
463- inducedRules, debug);
469+ System, inducedRules, debug);
464470 if (conflict) {
465471 recordConflict (key, *props->ConcreteTypeRule , ruleID, System);
466472 return ;
@@ -741,7 +747,8 @@ void PropertyMap::concretizeTypeWitnessInConformance(
741747 key, requirementKind, concreteType, typeWitness, subjectType,
742748 substitutions, path);
743749
744- inducedRules.emplace_back (constraintType, subjectType, path);
750+ assert (!path.empty ());
751+ (void ) System.addRule (constraintType, subjectType, &path);
745752 if (Debug.contains (DebugFlags::ConcretizeNestedTypes)) {
746753 llvm::dbgs () << " ^^ Induced rule " << constraintType
747754 << " => " << subjectType << " \n " ;
@@ -980,5 +987,5 @@ void PropertyMap::recordConcreteConformanceRule(
980987 // it to go in the other direction.
981988 path.invert ();
982989
983- inducedRules. emplace_back (std::move (lhs), std::move (rhs), std::move ( path) );
990+ ( void ) System. addRule (std::move (lhs), std::move (rhs), & path);
984991}
0 commit comments