@@ -170,16 +170,33 @@ void simple_display(llvm::raw_ostream &os, PropertyWrapperLValueness l);
170
170
// / be initialized out-of-line using an expression of the wrapped property type.
171
171
PropertyWrapperValuePlaceholderExpr *findWrappedValuePlaceholder (Expr *init);
172
172
173
- // / Describes the backing property of a property that has an attached wrapper.
174
- struct PropertyWrapperBackingPropertyInfo {
173
+ // / The synthesized auxiliary declarations for a wrapped property, including the
174
+ // / backing property wrapper, the projected value variable, and if the wrapped
175
+ // / declaration is a parameter, the local wrapped value variable.
176
+ struct PropertyWrapperAuxiliaryVariables {
175
177
// / The backing property.
176
178
VarDecl *backingVar = nullptr ;
177
179
178
180
// / The synthesized projection property, if any. When present, this takes the name
179
181
// / of the original wrapped property prefixed with \c $
180
182
VarDecl *projectionVar = nullptr ;
181
183
182
- private:
184
+ PropertyWrapperAuxiliaryVariables () {}
185
+
186
+ PropertyWrapperAuxiliaryVariables (VarDecl *backingVar, VarDecl *projectionVar)
187
+ : backingVar(backingVar), projectionVar(projectionVar) {}
188
+
189
+ // / Whether this is a valid property wrapper.
190
+ bool isValid () const {
191
+ return backingVar != nullptr ;
192
+ }
193
+
194
+ explicit operator bool () const { return isValid (); }
195
+ };
196
+
197
+ // / Describes how to initialize the backing storage of a property with
198
+ // / an attached wrapper.
199
+ class PropertyWrapperInitializerInfo {
183
200
struct {
184
201
// / An expression that initializes the backing property from a value of
185
202
// / the original property's type via \c init(wrappedValue:) if supported
@@ -203,15 +220,10 @@ struct PropertyWrapperBackingPropertyInfo {
203
220
} projectedValueInit;
204
221
205
222
public:
206
- PropertyWrapperBackingPropertyInfo () { }
207
-
208
- PropertyWrapperBackingPropertyInfo (VarDecl *backingVar, VarDecl *projectionVar)
209
- : backingVar(backingVar), projectionVar(projectionVar) { }
223
+ PropertyWrapperInitializerInfo () { }
210
224
211
- PropertyWrapperBackingPropertyInfo (VarDecl *backingVar, VarDecl *projectionVar,
212
- Expr *wrappedValueInitExpr,
213
- Expr *projectedValueInitExpr)
214
- : backingVar(backingVar), projectionVar(projectionVar) {
225
+ PropertyWrapperInitializerInfo (Expr *wrappedValueInitExpr,
226
+ Expr *projectedValueInitExpr) {
215
227
wrappedValueInit.expr = wrappedValueInitExpr;
216
228
if (wrappedValueInitExpr) {
217
229
wrappedValueInit.placeholder = findWrappedValuePlaceholder (wrappedValueInitExpr);
@@ -223,16 +235,11 @@ struct PropertyWrapperBackingPropertyInfo {
223
235
}
224
236
}
225
237
226
- // / Whether this is a valid property wrapper.
227
- bool isValid () const {
228
- return backingVar != nullptr ;
229
- }
230
-
231
238
bool hasInitFromWrappedValue () const {
232
239
return wrappedValueInit.expr != nullptr ;
233
240
}
234
241
235
- Expr *getInitFromWrappedValue () {
242
+ Expr *getInitFromWrappedValue () const {
236
243
return wrappedValueInit.expr ;
237
244
}
238
245
@@ -244,7 +251,7 @@ struct PropertyWrapperBackingPropertyInfo {
244
251
return projectedValueInit.expr != nullptr ;
245
252
}
246
253
247
- Expr *getInitFromProjectedValue () {
254
+ Expr *getInitFromProjectedValue () const {
248
255
return projectedValueInit.expr ;
249
256
}
250
257
@@ -255,14 +262,6 @@ struct PropertyWrapperBackingPropertyInfo {
255
262
bool hasSynthesizedInitializers () const {
256
263
return hasInitFromWrappedValue () || hasInitFromProjectedValue ();
257
264
}
258
-
259
- explicit operator bool () const { return isValid (); }
260
-
261
- friend bool operator ==(const PropertyWrapperBackingPropertyInfo &lhs,
262
- const PropertyWrapperBackingPropertyInfo &rhs) {
263
- // FIXME: Can't currently compare expressions.
264
- return lhs.backingVar == rhs.backingVar ;
265
- }
266
265
};
267
266
268
267
void simple_display (
@@ -271,7 +270,11 @@ void simple_display(
271
270
272
271
void simple_display (
273
272
llvm::raw_ostream &out,
274
- const PropertyWrapperBackingPropertyInfo &backingInfo);
273
+ const PropertyWrapperInitializerInfo &initInfo);
274
+
275
+ void simple_display (
276
+ llvm::raw_ostream &out,
277
+ const PropertyWrapperAuxiliaryVariables &auxiliaryVars);
275
278
276
279
} // end namespace swift
277
280
0 commit comments