@@ -106,25 +106,14 @@ bool InitLink::emit(Compiler<Emitter> *Ctx, const Expr *E) const {
106
106
return true ;
107
107
}
108
108
109
- // / Scope managing label targets.
110
- template <class Emitter > class LabelScope {
111
- public:
112
- virtual ~LabelScope () {}
113
-
114
- protected:
115
- LabelScope (Compiler<Emitter> *Ctx) : Ctx(Ctx) {}
116
- // / Compiler instance.
117
- Compiler<Emitter> *Ctx;
118
- };
119
-
120
109
// / Sets the context for break/continue statements.
121
- template <class Emitter > class LoopScope final : public LabelScope<Emitter> {
110
+ template <class Emitter > class LoopScope final {
122
111
public:
123
112
using LabelTy = typename Compiler<Emitter>::LabelTy;
124
113
using OptLabelTy = typename Compiler<Emitter>::OptLabelTy;
125
114
126
115
LoopScope (Compiler<Emitter> *Ctx, LabelTy BreakLabel, LabelTy ContinueLabel)
127
- : LabelScope<Emitter> (Ctx), OldBreakLabel(Ctx->BreakLabel),
116
+ : Ctx (Ctx), OldBreakLabel(Ctx->BreakLabel),
128
117
OldContinueLabel (Ctx->ContinueLabel),
129
118
OldBreakVarScope(Ctx->BreakVarScope),
130
119
OldContinueVarScope(Ctx->ContinueVarScope) {
@@ -142,22 +131,23 @@ template <class Emitter> class LoopScope final : public LabelScope<Emitter> {
142
131
}
143
132
144
133
private:
134
+ Compiler<Emitter> *Ctx;
145
135
OptLabelTy OldBreakLabel;
146
136
OptLabelTy OldContinueLabel;
147
137
VariableScope<Emitter> *OldBreakVarScope;
148
138
VariableScope<Emitter> *OldContinueVarScope;
149
139
};
150
140
151
141
// Sets the context for a switch scope, mapping labels.
152
- template <class Emitter > class SwitchScope final : public LabelScope<Emitter> {
142
+ template <class Emitter > class SwitchScope final {
153
143
public:
154
144
using LabelTy = typename Compiler<Emitter>::LabelTy;
155
145
using OptLabelTy = typename Compiler<Emitter>::OptLabelTy;
156
146
using CaseMap = typename Compiler<Emitter>::CaseMap;
157
147
158
148
SwitchScope (Compiler<Emitter> *Ctx, CaseMap &&CaseLabels, LabelTy BreakLabel,
159
149
OptLabelTy DefaultLabel)
160
- : LabelScope<Emitter> (Ctx), OldBreakLabel(Ctx->BreakLabel),
150
+ : Ctx (Ctx), OldBreakLabel(Ctx->BreakLabel),
161
151
OldDefaultLabel (this ->Ctx->DefaultLabel),
162
152
OldCaseLabels(std::move(this ->Ctx->CaseLabels)),
163
153
OldLabelVarScope(Ctx->BreakVarScope) {
@@ -175,6 +165,7 @@ template <class Emitter> class SwitchScope final : public LabelScope<Emitter> {
175
165
}
176
166
177
167
private:
168
+ Compiler<Emitter> *Ctx;
178
169
OptLabelTy OldBreakLabel;
179
170
OptLabelTy OldDefaultLabel;
180
171
CaseMap OldCaseLabels;
0 commit comments