@@ -5385,31 +5385,30 @@ getMagicFunctionString(SILGenFunction &SGF) {
5385
5385
}
5386
5386
5387
5387
// / Emit an application of the given allocating initializer.
5388
- static RValue emitApplyAllocatingInitializer (SILGenFunction &SGF,
5389
- SILLocation loc,
5390
- ConcreteDeclRef init,
5391
- RValue &&args,
5392
- Type overriddenSelfType,
5393
- SGFContext C) {
5388
+ RValue SILGenFunction::emitApplyAllocatingInitializer (SILLocation loc,
5389
+ ConcreteDeclRef init,
5390
+ RValue &&args,
5391
+ Type overriddenSelfType,
5392
+ SGFContext C) {
5394
5393
ConstructorDecl *ctor = cast<ConstructorDecl>(init.getDecl ());
5395
5394
5396
5395
// Form the reference to the allocating initializer.
5397
5396
auto initRef = SILDeclRef (ctor, SILDeclRef::Kind::Allocator)
5398
5397
.asForeign (requiresForeignEntryPoint (ctor));
5399
- auto initConstant = SGF. getConstantInfo (initRef);
5398
+ auto initConstant = getConstantInfo (initRef);
5400
5399
auto subs = init.getSubstitutions ();
5401
5400
5402
5401
// Scope any further writeback just within this operation.
5403
- FormalEvaluationScope writebackScope (SGF );
5402
+ FormalEvaluationScope writebackScope (* this );
5404
5403
5405
5404
// Form the metatype argument.
5406
5405
ManagedValue selfMetaVal;
5407
5406
SILType selfMetaTy;
5408
5407
{
5409
5408
// Determine the self metatype type.
5410
5409
CanSILFunctionType substFnType =
5411
- initConstant.SILFnType ->substGenericArgs (SGF. SGM .M , subs);
5412
- SILType selfParamMetaTy = SGF. getSILType (substFnType->getSelfParameter ());
5410
+ initConstant.SILFnType ->substGenericArgs (SGM.M , subs);
5411
+ SILType selfParamMetaTy = getSILType (substFnType->getSelfParameter ());
5413
5412
5414
5413
if (overriddenSelfType) {
5415
5414
// If the 'self' type has been overridden, form a metatype to the
@@ -5419,17 +5418,17 @@ static RValue emitApplyAllocatingInitializer(SILGenFunction &SGF,
5419
5418
selfParamMetaTy.castTo <MetatypeType>()
5420
5419
->getRepresentation ());
5421
5420
selfMetaTy =
5422
- SGF. getLoweredType (overriddenSelfMetaType->getCanonicalType ());
5421
+ getLoweredType (overriddenSelfMetaType->getCanonicalType ());
5423
5422
} else {
5424
5423
selfMetaTy = selfParamMetaTy;
5425
5424
}
5426
5425
5427
5426
// Form the metatype value.
5428
- SILValue selfMeta = SGF. B .createMetatype (loc, selfMetaTy);
5427
+ SILValue selfMeta = B.createMetatype (loc, selfMetaTy);
5429
5428
5430
5429
// If the types differ, we need an upcast.
5431
5430
if (selfMetaTy != selfParamMetaTy)
5432
- selfMeta = SGF. B .createUpcast (loc, selfMeta, selfParamMetaTy);
5431
+ selfMeta = B.createUpcast (loc, selfMeta, selfParamMetaTy);
5433
5432
5434
5433
selfMetaVal = ManagedValue::forUnmanaged (selfMeta);
5435
5434
}
@@ -5438,12 +5437,12 @@ static RValue emitApplyAllocatingInitializer(SILGenFunction &SGF,
5438
5437
Optional<Callee> callee;
5439
5438
if (isa<ProtocolDecl>(ctor->getDeclContext ())) {
5440
5439
callee.emplace (Callee::forWitnessMethod (
5441
- SGF , selfMetaVal.getType ().getASTType (),
5440
+ * this , selfMetaVal.getType ().getASTType (),
5442
5441
initRef, subs, loc));
5443
5442
} else if (getMethodDispatch (ctor) == MethodDispatch::Class) {
5444
- callee.emplace (Callee::forClassMethod (SGF , initRef, subs, loc));
5443
+ callee.emplace (Callee::forClassMethod (* this , initRef, subs, loc));
5445
5444
} else {
5446
- callee.emplace (Callee::forDirect (SGF , initRef, subs, loc));
5445
+ callee.emplace (Callee::forDirect (* this , initRef, subs, loc));
5447
5446
}
5448
5447
5449
5448
auto substFormalType = callee->getSubstFormalType ();
@@ -5461,12 +5460,12 @@ static RValue emitApplyAllocatingInitializer(SILGenFunction &SGF,
5461
5460
}
5462
5461
5463
5462
// Form the call emission.
5464
- CallEmission emission (SGF , std::move (*callee), std::move (writebackScope));
5463
+ CallEmission emission (* this , std::move (*callee), std::move (writebackScope));
5465
5464
5466
5465
// Self metatype.
5467
5466
emission.addCallSite (loc,
5468
5467
ArgumentSource (loc,
5469
- RValue (SGF , loc,
5468
+ RValue (* this , loc,
5470
5469
selfMetaVal.getType ()
5471
5470
.getASTType (),
5472
5471
std::move (selfMetaVal))),
@@ -5484,11 +5483,11 @@ static RValue emitApplyAllocatingInitializer(SILGenFunction &SGF,
5484
5483
5485
5484
// If we need a downcast, do it down.
5486
5485
if (requiresDowncast) {
5487
- ManagedValue v = std::move (result).getAsSingleValue (SGF , loc);
5486
+ ManagedValue v = std::move (result).getAsSingleValue (* this , loc);
5488
5487
CanType canOverriddenSelfType = overriddenSelfType->getCanonicalType ();
5489
- SILType loweredResultTy = SGF. getLoweredType (canOverriddenSelfType);
5490
- v = SGF. B .createUncheckedRefCast (loc, v, loweredResultTy);
5491
- result = RValue (SGF , loc, canOverriddenSelfType, v);
5488
+ SILType loweredResultTy = getLoweredType (canOverriddenSelfType);
5489
+ v = B.createUncheckedRefCast (loc, v, loweredResultTy);
5490
+ result = RValue (* this , loc, canOverriddenSelfType, v);
5492
5491
}
5493
5492
5494
5493
return result;
@@ -5556,7 +5555,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5556
5555
// Call the builtin initializer.
5557
5556
relabelArgument (builtinInit, builtinLiteralArgs);
5558
5557
RValue builtinLiteral =
5559
- emitApplyAllocatingInitializer (* this , literal, builtinInit,
5558
+ emitApplyAllocatingInitializer (literal, builtinInit,
5560
5559
std::move (builtinLiteralArgs),
5561
5560
Type (),
5562
5561
init ? SGFContext () : C);
@@ -5566,7 +5565,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5566
5565
5567
5566
// Otherwise, perform the second initialization step.
5568
5567
relabelArgument (init, builtinLiteral);
5569
- RValue result = emitApplyAllocatingInitializer (* this , literal, init,
5568
+ RValue result = emitApplyAllocatingInitializer (literal, init,
5570
5569
std::move (builtinLiteral),
5571
5570
literal->getType (), C);
5572
5571
return result;
0 commit comments