File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,16 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
190
190
// / Retrieve the UUID for an opened element environment.
191
191
UUID getOpenedElementUUID () const ;
192
192
193
+ using PackElementBinding =
194
+ std::pair<ElementArchetypeType *, PackArchetypeType *>;
195
+
196
+ // / Retrieve the bindings for the opened pack element archetypes in this
197
+ // / generic environment to the pack archetypes that contain them.
198
+ // /
199
+ // / \param bindings The vector to populate with the pack element bindings.
200
+ void getPackElementBindings (
201
+ SmallVectorImpl<PackElementBinding> &bindings) const ;
202
+
193
203
// / Create a new, primary generic environment.
194
204
static GenericEnvironment *forPrimary (GenericSignature signature);
195
205
Original file line number Diff line number Diff line change @@ -125,6 +125,33 @@ UUID GenericEnvironment::getOpenedElementUUID() const {
125
125
return getTrailingObjects<OpenedElementEnvironmentData>()->uuid ;
126
126
}
127
127
128
+ void GenericEnvironment::getPackElementBindings (
129
+ SmallVectorImpl<PackElementBinding> &bindings) const {
130
+ auto packElements = getGenericSignature ().getInnermostGenericParams ();
131
+ auto packElementDepth = packElements.front ()->getDepth ();
132
+ auto elementIt = packElements.begin ();
133
+
134
+ // Each parameter pack in the outer generic parameters has
135
+ // a corresponding pack element parameter at the innermost
136
+ // depth.
137
+ for (auto *genericParam : getGenericParams ()) {
138
+ if (genericParam->getDepth () == packElementDepth)
139
+ break ;
140
+
141
+ if (!genericParam->isParameterPack ())
142
+ continue ;
143
+
144
+ assert (elementIt != packElements.end ());
145
+ auto *elementArchetype =
146
+ mapTypeIntoContext (*elementIt++)->getAs <ElementArchetypeType>();
147
+ auto *packArchetype =
148
+ mapTypeIntoContext (genericParam)->getAs <PackArchetypeType>();
149
+
150
+ assert (elementArchetype && packArchetype);
151
+ bindings.emplace_back (elementArchetype, packArchetype);
152
+ }
153
+ }
154
+
128
155
GenericEnvironment::GenericEnvironment (GenericSignature signature)
129
156
: SignatureAndKind(signature, Kind::Primary)
130
157
{
You can’t perform that action at this time.
0 commit comments