@@ -38,7 +38,7 @@ struct RewriteStep {
38
38
// / *** Rewrite step kinds introduced by Knuth-Bendix completion ***
39
39
// /
40
40
41
- // / Apply a rewrite rule to the term at the top of the A stack.
41
+ // / Apply a rewrite rule to the term at the top of the primary stack.
42
42
// /
43
43
// / Formally, this is a whiskered, oriented rewrite rule. For example,
44
44
// / given a rule (X => Y) and the term A.X.B, the application at
@@ -54,7 +54,7 @@ struct RewriteStep {
54
54
// / The RuleID field encodes the rule to apply.
55
55
ApplyRewriteRule,
56
56
57
- // / The term at the top of the A stack must be a term ending with a
57
+ // / The term at the top of the primary stack must be a term ending with a
58
58
// / superclass or concrete type symbol.
59
59
// /
60
60
// / If not inverted: prepend the prefix to each substitution.
@@ -68,17 +68,17 @@ struct RewriteStep {
68
68
// / *** Rewrite step kinds introduced by simplifySubstitutions() ***
69
69
// /
70
70
71
- // / Move a term from the A stack to the B stack (if not inverted) or
72
- // / B stack to A stack (if inverted).
71
+ // / Move a term from the primary stack to the secondary stack (if not
72
+ // / inverted) or the secondary stack to primary stack (if inverted).
73
73
Shift,
74
74
75
- // / If not inverted: the top of the A stack must be a term ending with a
76
- // / superclass or concrete type symbol. Each concrete substitution in the
77
- // / term is pushed onto the A stack.
75
+ // / If not inverted: the top of the primary stack must be a term ending
76
+ // / with a superclass or concrete type symbol. Each concrete substitution
77
+ // / in the term is pushed onto the primary stack.
78
78
// /
79
- // / If inverted: pop concrete substitutions from the A stack, which must
80
- // / follow a term ending with a superclass or concrete type symbol. The
81
- // / new substitutions replace the substitutions in that symbol.
79
+ // / If inverted: pop concrete substitutions from the primary stack, which
80
+ // / must follow a term ending with a superclass or concrete type symbol.
81
+ // / The new substitutions replace the substitutions in that symbol.
82
82
// /
83
83
// / The RuleID field encodes the number of substitutions.
84
84
Decompose,
@@ -87,29 +87,29 @@ struct RewriteStep {
87
87
// / *** Rewrite step kinds introduced by the property map ***
88
88
// /
89
89
90
- // / If not inverted: the top of the A stack must be a term ending in a
91
- // / concrete type symbol [concrete: C] followed by a protocol symbol [P].
90
+ // / If not inverted: the top of the primary stack must be a term ending in
91
+ // / a concrete type symbol [concrete: C] followed by a protocol symbol [P].
92
92
// / These two symbols are combined into a single concrete conformance
93
93
// / symbol [concrete: C : P].
94
94
// /
95
- // / If inverted: the top of the A stack must be a term ending in a
95
+ // / If inverted: the top of the primary stack must be a term ending in a
96
96
// / concrete conformance symbol [concrete: C : P]. This symbol is replaced
97
97
// / with the concrete type symbol [concrete: C] followed by the protocol
98
98
// / symbol [P].
99
99
ConcreteConformance,
100
100
101
- // / If not inverted: the top of the A stack must be a term ending in a
102
- // / superclass symbol [superclass: C] followed by a protocol symbol [P].
101
+ // / If not inverted: the top of the primary stack must be a term ending in
102
+ // / a superclass symbol [superclass: C] followed by a protocol symbol [P].
103
103
// / These two symbols are combined into a single concrete conformance
104
104
// / symbol [concrete: C : P].
105
105
// /
106
- // / If inverted: the top of the A stack must be a term ending in a
106
+ // / If inverted: the top of the primary stack must be a term ending in a
107
107
// / concrete conformance symbol [concrete: C : P]. This symbol is replaced
108
108
// / with the superclass symbol [superclass: C] followed by the protocol
109
109
// / symbol [P].
110
110
SuperclassConformance,
111
111
112
- // / If not inverted: the top of the A stack must be a term ending in a
112
+ // / If not inverted: the top of the primary stack must be a term ending in a
113
113
// / concrete conformance symbol [concrete: C : P] followed by an associated
114
114
// / type symbol [P:X], and the concrete type symbol [concrete: C.X] for the
115
115
// / type witness of 'X' in the conformance 'C : P'. The concrete type symbol
@@ -123,7 +123,7 @@ struct RewriteStep {
123
123
// / the step.
124
124
ConcreteTypeWitness,
125
125
126
- // / If not inverted: the top of the A stack must be a term ending in a
126
+ // / If not inverted: the top of the primary stack must be a term ending in a
127
127
// / concrete conformance symbol [concrete: C : P] followed by an associated
128
128
// / type symbol [P:X]. The associated type symbol is eliminated.
129
129
// /
@@ -361,32 +361,36 @@ struct AppliedRewriteStep {
361
361
// / A rewrite path is a list of instructions for a two-stack interpreter.
362
362
// /
363
363
// / - ApplyRewriteRule and AdjustConcreteType manipulate the term at the top of
364
- // / the A stack.
364
+ // / the primary stack.
365
365
// /
366
366
// / - Shift moves a term from A to B (if not inverted) or B to A (if inverted).
367
367
// /
368
368
// / - Decompose splits off the substitutions from a superclass or concrete type
369
- // / symbol at the top of the A stack (if not inverted) or assembles a new
370
- // / superclass or concrete type symbol at the top of the A stack
369
+ // / symbol at the top of the primary stack (if not inverted) or assembles a
370
+ // / new superclass or concrete type symbol at the top of the primary stack
371
371
// / (if inverted).
372
372
struct RewritePathEvaluator {
373
- SmallVector<MutableTerm, 2 > A;
374
- SmallVector<MutableTerm, 2 > B;
373
+ // / The primary stack. Most rewrite steps operate on the top of this stack.
374
+ SmallVector<MutableTerm, 2 > Primary;
375
+
376
+ // / The secondary stack. The 'Shift' rewrite step moves terms between the
377
+ // / primary and secondary stacks.
378
+ SmallVector<MutableTerm, 2 > Secondary;
375
379
376
380
explicit RewritePathEvaluator (const MutableTerm &term) {
377
- A .push_back (term);
381
+ Primary .push_back (term);
378
382
}
379
383
380
- void checkA () const ;
381
- void checkB () const ;
384
+ void checkPrimary () const ;
385
+ void checkSecondary () const ;
382
386
383
387
MutableTerm &getCurrentTerm ();
384
388
385
389
// / We're "in context" if we're in the middle of rewriting concrete
386
390
// / substitutions.
387
391
bool isInContext () const {
388
- assert (A .size () > 0 );
389
- return (A .size () > 1 || B .size () > 0 );
392
+ assert (Primary .size () > 0 );
393
+ return (Primary .size () > 1 || Secondary .size () > 0 );
390
394
}
391
395
392
396
void apply (const RewriteStep &step,
0 commit comments