mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Factor out SILDeclRef::getInitializationExpr
This commit is contained in:
@@ -944,22 +944,10 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
|
||||
|
||||
auto *pbd = var->getParentPatternBinding();
|
||||
unsigned idx = pbd->getPatternEntryIndexForVarDecl(var);
|
||||
auto *init = pbd->getInit(idx);
|
||||
auto *initDC = pbd->getInitContext(idx);
|
||||
auto captureInfo = pbd->getCaptureInfo(idx);
|
||||
assert(!pbd->isInitializerSubsumed(idx));
|
||||
|
||||
// If this is the backing storage for a property with an attached wrapper
|
||||
// that was initialized with `=`, use that expression as the initializer.
|
||||
if (auto originalProperty = var->getOriginalWrappedProperty()) {
|
||||
if (originalProperty
|
||||
->isPropertyMemberwiseInitializedWithWrappedType()) {
|
||||
auto wrapperInfo =
|
||||
originalProperty->getPropertyWrapperInitializerInfo();
|
||||
assert(wrapperInfo.getWrappedValuePlaceholder()->getOriginalWrappedValue());
|
||||
init = wrapperInfo.getWrappedValuePlaceholder()->getOriginalWrappedValue();
|
||||
}
|
||||
}
|
||||
auto *init = constant.getInitializationExpr();
|
||||
assert(init);
|
||||
|
||||
auto loc = RegularLocation::getAutoGeneratedLocation(init);
|
||||
preEmitFunction(constant, f, loc);
|
||||
@@ -989,13 +977,14 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
|
||||
preEmitFunction(constant, f, loc);
|
||||
PrettyStackTraceSILFunction X(
|
||||
"silgen emitPropertyWrapperBackingInitializer", f);
|
||||
auto wrapperInfo = var->getPropertyWrapperInitializerInfo();
|
||||
assert(wrapperInfo.hasInitFromWrappedValue());
|
||||
f->createProfiler(wrapperInfo.getInitFromWrappedValue(), constant);
|
||||
|
||||
auto *init = constant.getInitializationExpr();
|
||||
assert(init);
|
||||
|
||||
f->createProfiler(init, constant);
|
||||
auto varDC = var->getInnermostDeclContext();
|
||||
SILGenFunction SGF(*this, *f, varDC);
|
||||
SGF.emitGeneratorFunction(constant, wrapperInfo.getInitFromWrappedValue(),
|
||||
/*EmitProfilerIncrement*/ true);
|
||||
SGF.emitGeneratorFunction(constant, init, /*EmitProfilerIncrement*/ true);
|
||||
postEmitFunction(constant, f);
|
||||
break;
|
||||
}
|
||||
@@ -1007,12 +996,14 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
|
||||
preEmitFunction(constant, f, loc);
|
||||
PrettyStackTraceSILFunction X(
|
||||
"silgen emitPropertyWrapperInitFromProjectedValue", f);
|
||||
auto initInfo = var->getPropertyWrapperInitializerInfo();
|
||||
assert(initInfo.hasInitFromProjectedValue());
|
||||
f->createProfiler(initInfo.getInitFromProjectedValue(), constant);
|
||||
|
||||
auto *init = constant.getInitializationExpr();
|
||||
assert(init);
|
||||
|
||||
f->createProfiler(init, constant);
|
||||
auto varDC = var->getInnermostDeclContext();
|
||||
SILGenFunction SGF(*this, *f, varDC);
|
||||
SGF.emitGeneratorFunction(constant, initInfo.getInitFromProjectedValue());
|
||||
SGF.emitGeneratorFunction(constant, init);
|
||||
postEmitFunction(constant, f);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user