@@ -1139,7 +1139,7 @@ class SubstGenericParametersFromWrittenArgs {
1139
1139
: allGenericArgs(allGenericArgs),
1140
1140
genericParamCounts(genericParamCounts) {}
1141
1141
1142
- const Metadata * getMetadata (unsigned depth, unsigned index) const ;
1142
+ MetadataOrPack getMetadata (unsigned depth, unsigned index) const ;
1143
1143
const WitnessTable *getWitnessTable (const Metadata *type,
1144
1144
unsigned index) const ;
1145
1145
};
@@ -1332,7 +1332,7 @@ _gatherGenericParameters(const ContextDescriptor *context,
1332
1332
auto error = _checkGenericRequirements (
1333
1333
generics->getGenericRequirements (), allGenericArgsVec,
1334
1334
[&substitutions](unsigned depth, unsigned index) {
1335
- return substitutions.getMetadata (depth, index);
1335
+ return substitutions.getMetadata (depth, index). Ptr ;
1336
1336
},
1337
1337
[&substitutions](const Metadata *type, unsigned index) {
1338
1338
return substitutions.getWitnessTable (type, index);
@@ -1577,7 +1577,8 @@ class DecodedMetadataBuilder {
1577
1577
swift_getTypeByMangledName (MetadataState::Complete,
1578
1578
mangledName, allGenericArgsVec.data (),
1579
1579
[&substitutions](unsigned depth, unsigned index) {
1580
- return substitutions.getMetadata (depth, index);
1580
+ // FIXME: Variadic generics
1581
+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
1581
1582
},
1582
1583
[&substitutions](const Metadata *type, unsigned index) {
1583
1584
return substitutions.getWitnessTable (type, index);
@@ -2172,7 +2173,8 @@ swift_getTypeByMangledNameInEnvironment(
2172
2173
MetadataState::Complete, typeName,
2173
2174
genericArgs,
2174
2175
[&substitutions](unsigned depth, unsigned index) {
2175
- return substitutions.getMetadata (depth, index);
2176
+ // FIXME: Variadic generics
2177
+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
2176
2178
},
2177
2179
[&substitutions](const Metadata *type, unsigned index) {
2178
2180
return substitutions.getWitnessTable (type, index);
@@ -2204,7 +2206,8 @@ swift_getTypeByMangledNameInEnvironmentInMetadataState(
2204
2206
(MetadataState)metadataState, typeName,
2205
2207
genericArgs,
2206
2208
[&substitutions](unsigned depth, unsigned index) {
2207
- return substitutions.getMetadata (depth, index);
2209
+ // FIXME: Variadic generics
2210
+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
2208
2211
},
2209
2212
[&substitutions](const Metadata *type, unsigned index) {
2210
2213
return substitutions.getWitnessTable (type, index);
@@ -2235,7 +2238,8 @@ swift_getTypeByMangledNameInContext(
2235
2238
MetadataState::Complete, typeName,
2236
2239
genericArgs,
2237
2240
[&substitutions](unsigned depth, unsigned index) {
2238
- return substitutions.getMetadata (depth, index);
2241
+ // FIXME: Variadic generics
2242
+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
2239
2243
},
2240
2244
[&substitutions](const Metadata *type, unsigned index) {
2241
2245
return substitutions.getWitnessTable (type, index);
@@ -2267,7 +2271,8 @@ swift_getTypeByMangledNameInContextInMetadataState(
2267
2271
(MetadataState)metadataState, typeName,
2268
2272
genericArgs,
2269
2273
[&substitutions](unsigned depth, unsigned index) {
2270
- return substitutions.getMetadata (depth, index);
2274
+ // FIXME: Variadic generics
2275
+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
2271
2276
},
2272
2277
[&substitutions](const Metadata *type, unsigned index) {
2273
2278
return substitutions.getWitnessTable (type, index);
@@ -2453,7 +2458,8 @@ swift_func_getReturnTypeInfo(const char *typeNameStart, size_t typeNameLength,
2453
2458
demangler,
2454
2459
/* substGenericParam=*/
2455
2460
[&substFn](unsigned depth, unsigned index) {
2456
- return substFn.getMetadata (depth, index);
2461
+ // FIXME: Variadic generics
2462
+ return substFn.getMetadata (depth, index).getMetadataOrNull ();
2457
2463
},
2458
2464
/* SubstDependentWitnessTableFn=*/
2459
2465
[&substFn](const Metadata *type, unsigned index) {
@@ -2494,7 +2500,8 @@ swift_func_getParameterTypeInfo(
2494
2500
demangler,
2495
2501
/* substGenericParam=*/
2496
2502
[&substFn](unsigned depth, unsigned index) {
2497
- return substFn.getMetadata (depth, index);
2503
+ // FIXME: Variadic generics
2504
+ return substFn.getMetadata (depth, index).getMetadataOrNull ();
2498
2505
},
2499
2506
/* SubstDependentWitnessTableFn=*/
2500
2507
[&substFn](const Metadata *type, unsigned index) {
@@ -2537,7 +2544,8 @@ swift_distributed_getWitnessTables(GenericEnvironmentDescriptor *genericEnv,
2537
2544
auto error = _checkGenericRequirements (
2538
2545
genericEnv->getGenericRequirements (), witnessTables,
2539
2546
[&substFn](unsigned depth, unsigned index) {
2540
- return substFn.getMetadata (depth, index);
2547
+ // FIXME: Variadic generics
2548
+ return substFn.getMetadata (depth, index).getMetadataOrNull ();
2541
2549
},
2542
2550
[&substFn](const Metadata *type, unsigned index) {
2543
2551
return substFn.getWitnessTable (type, index);
@@ -2571,7 +2579,8 @@ swift_getOpaqueTypeMetadata(MetadataRequest request,
2571
2579
return swift_getTypeByMangledName (request.getState (),
2572
2580
mangledName, arguments,
2573
2581
[&substitutions](unsigned depth, unsigned index) {
2574
- return substitutions.getMetadata (depth, index);
2582
+ // FIXME: Variadic generics
2583
+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
2575
2584
},
2576
2585
[&substitutions](const Metadata *type, unsigned index) {
2577
2586
return substitutions.getWitnessTable (type, index);
@@ -2823,22 +2832,22 @@ void SubstGenericParametersFromMetadata::setup() const {
2823
2832
}
2824
2833
}
2825
2834
2826
- const Metadata *
2835
+ MetadataOrPack
2827
2836
SubstGenericParametersFromMetadata::getMetadata (
2828
2837
unsigned depth, unsigned index) const {
2829
2838
// On first access, compute the descriptor path.
2830
2839
setup ();
2831
2840
2832
2841
// If the depth is too great, there is nothing to do.
2833
2842
if (depth >= descriptorPath.size ())
2834
- return nullptr ;
2843
+ return MetadataOrPack () ;
2835
2844
2836
2845
// / Retrieve the descriptor path element at this depth.
2837
2846
auto &pathElement = descriptorPath[depth];
2838
2847
2839
2848
// Check whether the index is clearly out of bounds.
2840
2849
if (index >= pathElement.numTotalGenericParams )
2841
- return nullptr ;
2850
+ return MetadataOrPack () ;
2842
2851
2843
2852
// Compute the flat index.
2844
2853
unsigned flatIndex = pathElement.numKeyGenericParamsInParent ;
@@ -2849,7 +2858,7 @@ SubstGenericParametersFromMetadata::getMetadata(
2849
2858
2850
2859
// Make sure that the requested parameter itself has a key argument.
2851
2860
if (!genericParams[index].hasKeyArgument ())
2852
- return nullptr ;
2861
+ return MetadataOrPack () ;
2853
2862
2854
2863
// Increase the flat index for each parameter with a key argument, up to
2855
2864
// the given index.
@@ -2861,7 +2870,7 @@ SubstGenericParametersFromMetadata::getMetadata(
2861
2870
flatIndex += index;
2862
2871
}
2863
2872
2864
- return ( const Metadata *) genericArgs[flatIndex];
2873
+ return MetadataOrPack ( genericArgs[flatIndex]) ;
2865
2874
}
2866
2875
2867
2876
const WitnessTable *
@@ -2873,17 +2882,16 @@ SubstGenericParametersFromMetadata::getWitnessTable(const Metadata *type,
2873
2882
return (const WitnessTable *)genericArgs[index + numKeyGenericParameters];
2874
2883
}
2875
2884
2876
- const Metadata * SubstGenericParametersFromWrittenArgs::getMetadata (
2885
+ MetadataOrPack SubstGenericParametersFromWrittenArgs::getMetadata (
2877
2886
unsigned depth, unsigned index) const {
2878
2887
if (auto flatIndex =
2879
2888
_depthIndexToFlatIndex (depth, index, genericParamCounts)) {
2880
2889
if (*flatIndex < allGenericArgs.size ()) {
2881
- // FIXME: variadic generics
2882
- return allGenericArgs[*flatIndex].getMetadata ();
2890
+ return MetadataOrPack (allGenericArgs[*flatIndex]);
2883
2891
}
2884
2892
}
2885
2893
2886
- return nullptr ;
2894
+ return MetadataOrPack () ;
2887
2895
}
2888
2896
2889
2897
const WitnessTable *
@@ -3009,7 +3017,8 @@ static void _gatherWrittenGenericArgs(
3009
3017
req.getMangledTypeName (),
3010
3018
(const void * const *)allGenericArgs.data (),
3011
3019
[&substitutions](unsigned depth, unsigned index) {
3012
- return substitutions.getMetadata (depth, index);
3020
+ // FIXME: Variadic generics
3021
+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
3013
3022
},
3014
3023
[&substitutions](const Metadata *type, unsigned index) {
3015
3024
return substitutions.getWitnessTable (type, index);
0 commit comments