@@ -47,128 +47,29 @@ SILGenSILBuilder::SILGenSILBuilder(SILGenFunction &SGF, SILBasicBlock *insertBB,
47
47
// SILBuilder APIs directly.
48
48
//
49
49
50
- MetatypeInst *SILGenSILBuilder::createMetatype (SILLocation loc,
51
- SILType metatype) {
52
- auto theMetatype = metatype.castTo <MetatypeType>();
53
- // Getting a nontrivial metatype requires forcing any conformances necessary
54
- // to instantiate the type.
55
- switch (theMetatype->getRepresentation ()) {
56
- case MetatypeRepresentation::Thin:
57
- break ;
58
- case MetatypeRepresentation::Thick:
59
- case MetatypeRepresentation::ObjC: {
60
- // Walk the type recursively to look for substitutions we may need.
61
- theMetatype.getInstanceType ().findIf ([&](Type t) -> bool {
62
- auto *decl = t->getAnyNominal ();
63
- if (!decl)
64
- return false ;
65
-
66
- if (isa<ProtocolDecl>(decl))
67
- return false ;
68
-
69
- auto *genericSig = decl->getGenericSignature ();
70
- if (!genericSig)
71
- return false ;
72
-
73
- auto subMap =
74
- t->getContextSubstitutionMap (getSILGenModule ().SwiftModule , decl);
75
- getSILGenModule ().useConformancesFromSubstitutions (subMap);
76
- return false ;
77
- });
78
-
79
- break ;
80
- }
81
- }
82
-
83
- return SILBuilder::createMetatype (loc, metatype);
84
- }
85
-
86
50
ApplyInst *SILGenSILBuilder::createApply (SILLocation loc, SILValue fn,
87
51
SILType substFnTy, SILType result,
88
52
SubstitutionMap subs,
89
53
ArrayRef<SILValue> args) {
90
- getSILGenModule ().useConformancesFromSubstitutions (subs);
91
54
return SILBuilder::createApply (loc, fn, subs, args, false );
92
55
}
93
56
94
57
TryApplyInst *SILGenSILBuilder::createTryApply (
95
58
SILLocation loc, SILValue fn, SILType substFnTy, SubstitutionMap subs,
96
59
ArrayRef<SILValue> args, SILBasicBlock *normalBB, SILBasicBlock *errorBB) {
97
- getSILGenModule ().useConformancesFromSubstitutions (subs);
98
60
return SILBuilder::createTryApply (loc, fn, subs, args, normalBB, errorBB);
99
61
}
100
62
101
63
BeginApplyInst *SILGenSILBuilder::createBeginApply (SILLocation loc, SILValue fn,
102
64
SubstitutionMap subs,
103
65
ArrayRef<SILValue> args) {
104
- getSILGenModule ().useConformancesFromSubstitutions (subs);
105
66
return SILBuilder::createBeginApply (loc, fn, subs, args, false );
106
67
}
107
68
108
69
PartialApplyInst *SILGenSILBuilder::createPartialApply (
109
70
SILLocation loc, SILValue fn, SILType substFnTy, SubstitutionMap subs,
110
71
ArrayRef<SILValue> args, SILType closureTy) {
111
- getSILGenModule ().useConformancesFromSubstitutions (subs);
112
72
return SILBuilder::createPartialApply (
113
73
loc, fn, subs, args,
114
74
closureTy.getAs <SILFunctionType>()->getCalleeConvention ());
115
75
}
116
-
117
- BuiltinInst *SILGenSILBuilder::createBuiltin (SILLocation loc, Identifier name,
118
- SILType resultTy,
119
- SubstitutionMap subs,
120
- ArrayRef<SILValue> args) {
121
- getSILGenModule ().useConformancesFromSubstitutions (subs);
122
- return SILBuilder::createBuiltin (loc, name, resultTy, subs, args);
123
- }
124
-
125
- InitExistentialAddrInst *SILGenSILBuilder::createInitExistentialAddr (
126
- SILLocation loc, SILValue existential, CanType formalConcreteType,
127
- SILType loweredConcreteType,
128
- ArrayRef<ProtocolConformanceRef> conformances) {
129
- for (auto conformance : conformances)
130
- getSILGenModule ().useConformance (conformance);
131
-
132
- return SILBuilder::createInitExistentialAddr (
133
- loc, existential, formalConcreteType, loweredConcreteType, conformances);
134
- }
135
-
136
- InitExistentialValueInst *SILGenSILBuilder::createInitExistentialValue (
137
- SILLocation Loc, SILType ExistentialType, CanType FormalConcreteType,
138
- SILValue Concrete, ArrayRef<ProtocolConformanceRef> Conformances) {
139
- for (auto conformance : Conformances)
140
- getSILGenModule ().useConformance (conformance);
141
-
142
- return SILBuilder::createInitExistentialValue (
143
- Loc, ExistentialType, FormalConcreteType, Concrete, Conformances);
144
- }
145
-
146
- InitExistentialMetatypeInst *SILGenSILBuilder::createInitExistentialMetatype (
147
- SILLocation loc, SILValue metatype, SILType existentialType,
148
- ArrayRef<ProtocolConformanceRef> conformances) {
149
- for (auto conformance : conformances)
150
- getSILGenModule ().useConformance (conformance);
151
-
152
- return SILBuilder::createInitExistentialMetatype (
153
- loc, metatype, existentialType, conformances);
154
- }
155
-
156
- InitExistentialRefInst *SILGenSILBuilder::createInitExistentialRef (
157
- SILLocation loc, SILType existentialType, CanType formalConcreteType,
158
- SILValue concreteValue, ArrayRef<ProtocolConformanceRef> conformances) {
159
- for (auto conformance : conformances)
160
- getSILGenModule ().useConformance (conformance);
161
-
162
- return SILBuilder::createInitExistentialRef (
163
- loc, existentialType, formalConcreteType, concreteValue, conformances);
164
- }
165
-
166
- AllocExistentialBoxInst *SILGenSILBuilder::createAllocExistentialBox (
167
- SILLocation loc, SILType existentialType, CanType concreteType,
168
- ArrayRef<ProtocolConformanceRef> conformances) {
169
- for (auto conformance : conformances)
170
- getSILGenModule ().useConformance (conformance);
171
-
172
- return SILBuilder::createAllocExistentialBox (loc, existentialType,
173
- concreteType, conformances);
174
- }
0 commit comments