@@ -256,12 +256,9 @@ class Callee {
256
256
private:
257
257
union {
258
258
ManagedValue IndirectValue;
259
- SILDeclRef StandaloneFunction;
260
- struct {
261
- SILValue SelfValue;
262
- SILDeclRef MethodName;
263
- } Method;
259
+ SILDeclRef Constant;
264
260
};
261
+ SILValue SelfValue;
265
262
ArrayRef<Substitution> Substitutions;
266
263
CanType OrigFormalOldType;
267
264
CanType OrigFormalInterfaceType;
@@ -304,7 +301,7 @@ class Callee {
304
301
Callee (SILGenFunction &gen, SILDeclRef standaloneFunction,
305
302
CanAnyFunctionType substFormalType,
306
303
SILLocation l)
307
- : kind(Kind::StandaloneFunction), StandaloneFunction (standaloneFunction),
304
+ : kind(Kind::StandaloneFunction), Constant (standaloneFunction),
308
305
OrigFormalOldType(getConstantFormalType(gen, SILValue(),
309
306
standaloneFunction)),
310
307
OrigFormalInterfaceType(getConstantFormalInterfaceType(gen, SILValue(),
@@ -320,7 +317,7 @@ class Callee {
320
317
SILDeclRef methodName,
321
318
CanAnyFunctionType substFormalType,
322
319
SILLocation l)
323
- : kind(methodKind), Method{selfValue, methodName} ,
320
+ : kind(methodKind), Constant(methodName), SelfValue(selfValue) ,
324
321
OrigFormalOldType(getConstantFormalType(gen, selfValue, methodName)),
325
322
OrigFormalInterfaceType(getConstantFormalInterfaceType(gen, selfValue,
326
323
methodName)),
@@ -437,9 +434,9 @@ class Callee {
437
434
438
435
// Replace it with the dynamic self type.
439
436
OrigFormalOldType = OrigFormalInterfaceType
440
- = getDynamicMethodFormalType (SGM, Method. SelfValue ,
441
- Method. MethodName .getDecl (),
442
- Method. MethodName , methodType);
437
+ = getDynamicMethodFormalType (SGM, SelfValue,
438
+ Constant .getDecl (),
439
+ Constant , methodType);
443
440
444
441
// Add a self clause to the substituted type.
445
442
auto origFormalType = cast<AnyFunctionType>(OrigFormalOldType);
@@ -533,13 +530,11 @@ class Callee {
533
530
return 0 ;
534
531
535
532
case Kind::StandaloneFunction:
536
- return StandaloneFunction.uncurryLevel ;
537
-
538
533
case Kind::ClassMethod:
539
534
case Kind::SuperMethod:
540
535
case Kind::WitnessMethod:
541
536
case Kind::DynamicMethod:
542
- return Method. MethodName .uncurryLevel ;
537
+ return Constant .uncurryLevel ;
543
538
}
544
539
}
545
540
@@ -559,14 +554,14 @@ class Callee {
559
554
break ;
560
555
561
556
case Kind::StandaloneFunction: {
562
- assert (level <= StandaloneFunction .uncurryLevel
557
+ assert (level <= Constant .uncurryLevel
563
558
&& " uncurrying past natural uncurry level of standalone function" );
564
- constant = StandaloneFunction .atUncurryLevel (level);
559
+ constant = Constant .atUncurryLevel (level);
565
560
566
561
// If we're currying a direct reference to a class-dispatched method,
567
562
// make sure we emit the right set of thunks.
568
- if (constant->isCurried && StandaloneFunction .hasDecl ())
569
- if (auto func = StandaloneFunction .getAbstractFunctionDecl ())
563
+ if (constant->isCurried && Constant .hasDecl ())
564
+ if (auto func = Constant .getAbstractFunctionDecl ())
570
565
if (gen.getMethodDispatch (func) == MethodDispatch::Class)
571
566
constant = constant->asDirectReference (true );
572
567
@@ -576,21 +571,21 @@ class Callee {
576
571
break ;
577
572
}
578
573
case Kind::ClassMethod: {
579
- assert (level <= Method. MethodName .uncurryLevel
574
+ assert (level <= Constant .uncurryLevel
580
575
&& " uncurrying past natural uncurry level of method" );
581
- constant = Method. MethodName .atUncurryLevel (level);
576
+ constant = Constant .atUncurryLevel (level);
582
577
constantInfo = gen.getConstantInfo (*constant);
583
578
584
579
// If the call is curried, emit a direct call to the curry thunk.
585
- if (level < Method. MethodName .uncurryLevel ) {
580
+ if (level < Constant .uncurryLevel ) {
586
581
SILValue ref = gen.emitGlobalFunctionRef (Loc, *constant, constantInfo);
587
582
mv = ManagedValue::forUnmanaged (ref);
588
583
break ;
589
584
}
590
585
591
586
// Otherwise, do the dynamic dispatch inline.
592
587
SILValue methodVal = gen.B .createClassMethod (Loc,
593
- Method. SelfValue ,
588
+ SelfValue,
594
589
*constant,
595
590
/* volatile*/
596
591
constant->isForeign );
@@ -599,15 +594,15 @@ class Callee {
599
594
break ;
600
595
}
601
596
case Kind::SuperMethod: {
602
- assert (level <= Method. MethodName .uncurryLevel
597
+ assert (level <= Constant .uncurryLevel
603
598
&& " uncurrying past natural uncurry level of method" );
604
599
assert (level >= 1
605
600
&& " currying 'self' of super method dispatch not yet supported" );
606
601
607
- constant = Method. MethodName .atUncurryLevel (level);
602
+ constant = Constant .atUncurryLevel (level);
608
603
constantInfo = gen.getConstantInfo (*constant);
609
604
SILValue methodVal = gen.B .createSuperMethod (Loc,
610
- Method. SelfValue ,
605
+ SelfValue,
611
606
*constant,
612
607
constantInfo.getSILType (),
613
608
/* volatile*/
@@ -617,13 +612,13 @@ class Callee {
617
612
break ;
618
613
}
619
614
case Kind::WitnessMethod: {
620
- assert (level <= Method. MethodName .uncurryLevel
615
+ assert (level <= Constant .uncurryLevel
621
616
&& " uncurrying past natural uncurry level of method" );
622
- constant = Method. MethodName .atUncurryLevel (level);
617
+ constant = Constant .atUncurryLevel (level);
623
618
constantInfo = gen.getConstantInfo (*constant);
624
619
625
620
// If the call is curried, emit a direct call to the curry thunk.
626
- if (level < Method. MethodName .uncurryLevel ) {
621
+ if (level < Constant .uncurryLevel ) {
627
622
SILValue ref = gen.emitGlobalFunctionRef (Loc, *constant, constantInfo);
628
623
mv = ManagedValue::forUnmanaged (ref);
629
624
break ;
@@ -636,7 +631,7 @@ class Callee {
636
631
// existential type.
637
632
SILValue OpenedExistential;
638
633
if (!archetype->getOpenedExistentialType ().isNull ())
639
- OpenedExistential = Method. SelfValue ;
634
+ OpenedExistential = SelfValue;
640
635
641
636
SILValue fn = gen.B .createWitnessMethod (Loc,
642
637
archetype,
@@ -651,20 +646,20 @@ class Callee {
651
646
case Kind::DynamicMethod: {
652
647
assert (level >= 1
653
648
&& " currying 'self' of dynamic method dispatch not yet supported" );
654
- assert (level <= Method. MethodName .uncurryLevel
649
+ assert (level <= Constant .uncurryLevel
655
650
&& " uncurrying past natural uncurry level of method" );
656
651
657
- auto constant = Method. MethodName .atUncurryLevel (level);
652
+ auto constant = Constant .atUncurryLevel (level);
658
653
constantInfo = gen.getConstantInfo (constant);
659
654
660
655
auto closureType =
661
656
replaceSelfTypeForDynamicLookup (gen.getASTContext (),
662
657
constantInfo.SILFnType ,
663
- Method. SelfValue .getType ().getSwiftRValueType (),
664
- Method. MethodName );
658
+ SelfValue.getType ().getSwiftRValueType (),
659
+ Constant );
665
660
666
661
SILValue fn = gen.B .createDynamicMethod (Loc,
667
- Method. SelfValue ,
662
+ SelfValue,
668
663
constant,
669
664
SILType::getPrimitiveObjectType (closureType),
670
665
/* volatile*/ constant.isForeign );
@@ -692,7 +687,7 @@ class Callee {
692
687
}
693
688
694
689
SILDeclRef getMethodName () const {
695
- return Method. MethodName ;
690
+ return Constant ;
696
691
}
697
692
698
693
// / Return a specialized emission function if this is a function with a known
@@ -706,7 +701,7 @@ class Callee {
706
701
707
702
switch (kind) {
708
703
case Kind::StandaloneFunction: {
709
- return SpecializedEmitter::forDecl (SGM, StandaloneFunction );
704
+ return SpecializedEmitter::forDecl (SGM, Constant );
710
705
}
711
706
case Kind::SuperMethod: {
712
707
return SpecializedEmitter (emitPartialSuperMethod);
0 commit comments