@@ -51,7 +51,7 @@ struct RewriteStep {
5151 // /
5252 // / The StartOffset field encodes the offset where to apply the rule.
5353 // /
54- // / The RuleID field encodes the rule to apply.
54+ // / The Arg field encodes the rule to apply.
5555 ApplyRewriteRule,
5656
5757 // / The term at the top of the primary stack must be a term ending with a
@@ -80,7 +80,7 @@ struct RewriteStep {
8080 // / must follow a term ending with a superclass or concrete type symbol.
8181 // / The new substitutions replace the substitutions in that symbol.
8282 // /
83- // / The RuleID field encodes the number of substitutions.
83+ // / The Arg field encodes the number of substitutions.
8484 Decompose,
8585
8686 // /
@@ -117,10 +117,7 @@ struct RewriteStep {
117117 // /
118118 // / If inverted: the concrete type symbol [concrete: C.X] is introduced.
119119 // /
120- // / The RuleID field is repurposed to store the result of calling
121- // / RewriteSystem::recordTypeWitness(). This index is then passed in
122- // / to RewriteSystem::getTypeWitness() when applying
123- // / the step.
120+ // / The Arg field stores the result of RewriteSystem::recordTypeWitness().
124121 ConcreteTypeWitness,
125122
126123 // / If not inverted: the top of the primary stack must be a term ending in a
@@ -129,8 +126,7 @@ struct RewriteStep {
129126 // /
130127 // / If inverted: the associated type symbol [P:X] is introduced.
131128 // /
132- // / The RuleID field is a TypeWitness ID as above.
133- // / the step.
129+ // / The Arg field stores the result of RewriteSystem::recordTypeWitness().
134130 SameTypeWitness,
135131
136132 // / If not inverted: replaces the abstract type witness term with the
@@ -139,7 +135,7 @@ struct RewriteStep {
139135 // / If inverted: replaces the subject type term with the abstract type
140136 // / term.
141137 // /
142- // / The RuleID field is a TypeWitness ID as above .
138+ // / The Arg field stores the result of RewriteSystem::recordTypeWitness() .
143139 AbstractTypeWitness,
144140 };
145141
@@ -164,18 +160,18 @@ struct RewriteStep {
164160 // / at the beginning of each concrete substitution.
165161 // /
166162 // / If Kind is Concrete, the number of substitutions to push or pop.
167- unsigned RuleID : 16 ;
163+ unsigned Arg : 16 ;
168164
169165 RewriteStep (StepKind kind, unsigned startOffset, unsigned endOffset,
170- unsigned ruleID , bool inverse) {
166+ unsigned arg , bool inverse) {
171167 Kind = kind;
172168
173169 StartOffset = startOffset;
174170 assert (StartOffset == startOffset && " Overflow" );
175171 EndOffset = endOffset;
176172 assert (EndOffset == endOffset && " Overflow" );
177- RuleID = ruleID ;
178- assert (RuleID == ruleID && " Overflow" );
173+ Arg = arg ;
174+ assert (Arg == arg && " Overflow" );
179175 Inverse = inverse;
180176 }
181177
@@ -187,42 +183,42 @@ struct RewriteStep {
187183 static RewriteStep forAdjustment (unsigned offset, unsigned endOffset,
188184 bool inverse) {
189185 return RewriteStep (AdjustConcreteType, /* startOffset=*/ 0 , endOffset,
190- /* ruleID =*/ offset, inverse);
186+ /* arg =*/ offset, inverse);
191187 }
192188
193189 static RewriteStep forShift (bool inverse) {
194190 return RewriteStep (Shift, /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
195- /* ruleID =*/ 0 , inverse);
191+ /* arg =*/ 0 , inverse);
196192 }
197193
198194 static RewriteStep forDecompose (unsigned numSubstitutions, bool inverse) {
199195 return RewriteStep (Decompose, /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
200- /* ruleID =*/ numSubstitutions, inverse);
196+ /* arg =*/ numSubstitutions, inverse);
201197 }
202198
203199 static RewriteStep forConcreteConformance (bool inverse) {
204200 return RewriteStep (ConcreteConformance, /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
205- /* ruleID =*/ 0 , inverse);
201+ /* arg =*/ 0 , inverse);
206202 }
207203
208204 static RewriteStep forSuperclassConformance (bool inverse) {
209205 return RewriteStep (SuperclassConformance, /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
210- /* ruleID =*/ 0 , inverse);
206+ /* arg =*/ 0 , inverse);
211207 }
212208
213209 static RewriteStep forConcreteTypeWitness (unsigned witnessID, bool inverse) {
214210 return RewriteStep (ConcreteTypeWitness, /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
215- /* ruleID =*/ witnessID, inverse);
211+ /* arg =*/ witnessID, inverse);
216212 }
217213
218214 static RewriteStep forSameTypeWitness (unsigned witnessID, bool inverse) {
219215 return RewriteStep (SameTypeWitness, /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
220- /* ruleID =*/ witnessID, inverse);
216+ /* arg =*/ witnessID, inverse);
221217 }
222218
223219 static RewriteStep forAbstractTypeWitness (unsigned witnessID, bool inverse) {
224220 return RewriteStep (AbstractTypeWitness, /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
225- /* ruleID =*/ witnessID, inverse);
221+ /* arg =*/ witnessID, inverse);
226222 }
227223
228224 bool isInContext () const {
@@ -233,10 +229,10 @@ struct RewriteStep {
233229 Inverse = !Inverse;
234230 }
235231
236- bool isInverseOf ( const RewriteStep &other ) const ;
237-
238- bool maybeSwapRewriteSteps (RewriteStep &other,
239- const RewriteSystem &system);
232+ unsigned getRuleID ( ) const {
233+ assert (Kind == RewriteStep::ApplyRewriteRule);
234+ return Arg;
235+ }
240236
241237 void dump (llvm::raw_ostream &out,
242238 RewritePathEvaluator &evaluator,
0 commit comments