@@ -38,7 +38,7 @@ struct RewriteStep {
3838 // / *** Rewrite step kinds introduced by Knuth-Bendix completion ***
3939 // /
4040
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.
4242 // /
4343 // / Formally, this is a whiskered, oriented rewrite rule. For example,
4444 // / given a rule (X => Y) and the term A.X.B, the application at
@@ -54,7 +54,7 @@ struct RewriteStep {
5454 // / The RuleID field encodes the rule to apply.
5555 ApplyRewriteRule,
5656
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
5858 // / superclass or concrete type symbol.
5959 // /
6060 // / If not inverted: prepend the prefix to each substitution.
@@ -68,17 +68,17 @@ struct RewriteStep {
6868 // / *** Rewrite step kinds introduced by simplifySubstitutions() ***
6969 // /
7070
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).
7373 Shift,
7474
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.
7878 // /
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.
8282 // /
8383 // / The RuleID field encodes the number of substitutions.
8484 Decompose,
@@ -87,29 +87,29 @@ struct RewriteStep {
8787 // / *** Rewrite step kinds introduced by the property map ***
8888 // /
8989
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].
9292 // / These two symbols are combined into a single concrete conformance
9393 // / symbol [concrete: C : P].
9494 // /
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
9696 // / concrete conformance symbol [concrete: C : P]. This symbol is replaced
9797 // / with the concrete type symbol [concrete: C] followed by the protocol
9898 // / symbol [P].
9999 ConcreteConformance,
100100
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].
103103 // / These two symbols are combined into a single concrete conformance
104104 // / symbol [concrete: C : P].
105105 // /
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
107107 // / concrete conformance symbol [concrete: C : P]. This symbol is replaced
108108 // / with the superclass symbol [superclass: C] followed by the protocol
109109 // / symbol [P].
110110 SuperclassConformance,
111111
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
113113 // / concrete conformance symbol [concrete: C : P] followed by an associated
114114 // / type symbol [P:X], and the concrete type symbol [concrete: C.X] for the
115115 // / type witness of 'X' in the conformance 'C : P'. The concrete type symbol
@@ -123,7 +123,7 @@ struct RewriteStep {
123123 // / the step.
124124 ConcreteTypeWitness,
125125
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
127127 // / concrete conformance symbol [concrete: C : P] followed by an associated
128128 // / type symbol [P:X]. The associated type symbol is eliminated.
129129 // /
@@ -361,32 +361,36 @@ struct AppliedRewriteStep {
361361// / A rewrite path is a list of instructions for a two-stack interpreter.
362362// /
363363// / - ApplyRewriteRule and AdjustConcreteType manipulate the term at the top of
364- // / the A stack.
364+ // / the primary stack.
365365// /
366366// / - Shift moves a term from A to B (if not inverted) or B to A (if inverted).
367367// /
368368// / - 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
371371// / (if inverted).
372372struct 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;
375379
376380 explicit RewritePathEvaluator (const MutableTerm &term) {
377- A .push_back (term);
381+ Primary .push_back (term);
378382 }
379383
380- void checkA () const ;
381- void checkB () const ;
384+ void checkPrimary () const ;
385+ void checkSecondary () const ;
382386
383387 MutableTerm &getCurrentTerm ();
384388
385389 // / We're "in context" if we're in the middle of rewriting concrete
386390 // / substitutions.
387391 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 );
390394 }
391395
392396 void apply (const RewriteStep &step,
0 commit comments