@@ -2278,6 +2278,13 @@ struct TargetTypeMetadataRecord {
2278
2278
2279
2279
using TypeMetadataRecord = TargetTypeMetadataRecord<InProcess>;
2280
2280
2281
+ template <typename Runtime> struct TargetContextDescriptor ;
2282
+
2283
+ template <typename Runtime>
2284
+ using RelativeContextPointer =
2285
+ RelativeIndirectablePointer<const TargetContextDescriptor<Runtime>,
2286
+ /* nullable*/ true >;
2287
+
2281
2288
// / The structure of a protocol reference record.
2282
2289
template <typename Runtime>
2283
2290
struct TargetProtocolRecord {
@@ -2290,18 +2297,37 @@ struct TargetProtocolRecord {
2290
2297
};
2291
2298
using ProtocolRecord = TargetProtocolRecord<InProcess>;
2292
2299
2300
+ template <typename Runtime> class TargetGenericRequirementDescriptor ;
2301
+
2293
2302
// / The structure of a protocol conformance.
2294
2303
// /
2295
2304
// / This contains enough static information to recover the witness table for a
2296
2305
// / type's conformance to a protocol.
2297
2306
template <typename Runtime>
2298
- struct TargetProtocolConformanceDescriptor {
2307
+ struct TargetProtocolConformanceDescriptor final
2308
+ : public swift::ABI::TrailingObjects<
2309
+ TargetProtocolConformanceDescriptor<Runtime>,
2310
+ RelativeContextPointer<Runtime>,
2311
+ TargetGenericRequirementDescriptor<Runtime>> {
2312
+
2313
+ using TrailingObjects = swift::ABI::TrailingObjects<
2314
+ TargetProtocolConformanceDescriptor<Runtime>,
2315
+ RelativeContextPointer<Runtime>,
2316
+ TargetGenericRequirementDescriptor<Runtime>>;
2317
+ friend TrailingObjects;
2318
+
2319
+ template <typename T>
2320
+ using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
2321
+
2299
2322
public:
2300
2323
using WitnessTableAccessorFn
2301
2324
= const TargetWitnessTable<Runtime> *(const TargetMetadata<Runtime>*,
2302
2325
const TargetWitnessTable<Runtime> **,
2303
2326
size_t );
2304
2327
2328
+ using GenericRequirementDescriptor =
2329
+ TargetGenericRequirementDescriptor<Runtime>;
2330
+
2305
2331
private:
2306
2332
// / The protocol being conformed to.
2307
2333
// /
@@ -2381,7 +2407,22 @@ struct TargetProtocolConformanceDescriptor {
2381
2407
2382
2408
return nullptr ;
2383
2409
}
2384
-
2410
+
2411
+ // / Retrieve the context of a retroactive conformance.
2412
+ const TargetContextDescriptor<Runtime> *getRetroactiveContext () const {
2413
+ if (!Flags.isRetroactive ()) return nullptr ;
2414
+
2415
+ return this ->template getTrailingObjects <RelativeContextPointer<Runtime>>();
2416
+ }
2417
+
2418
+ // / Retrieve the conditional requirements that must also be
2419
+ // / satisfied
2420
+ llvm::ArrayRef<GenericRequirementDescriptor>
2421
+ getConditionalRequirements () const {
2422
+ return {this ->template getTrailingObjects <GenericRequirementDescriptor>(),
2423
+ Flags.getNumConditionalRequirements ()};
2424
+ }
2425
+
2385
2426
// / Get the directly-referenced static witness table.
2386
2427
const swift::TargetWitnessTable<Runtime> *getStaticWitnessTable () const {
2387
2428
switch (getConformanceKind ()) {
@@ -2416,7 +2457,7 @@ struct TargetProtocolConformanceDescriptor {
2416
2457
// / type.
2417
2458
const swift::TargetWitnessTable<Runtime> *
2418
2459
getWitnessTable (const TargetMetadata<Runtime> *type) const ;
2419
-
2460
+
2420
2461
#if !defined(NDEBUG) && SWIFT_OBJC_INTEROP
2421
2462
void dump () const ;
2422
2463
#endif
@@ -2430,6 +2471,16 @@ struct TargetProtocolConformanceDescriptor {
2430
2471
// / 2. Has a valid conformance kind.
2431
2472
void verify () const LLVM_ATTRIBUTE_USED;
2432
2473
#endif
2474
+
2475
+ private:
2476
+ size_t numTrailingObjects (
2477
+ OverloadToken<RelativeContextPointer<Runtime>>) const {
2478
+ return Flags.isRetroactive () ? 1 : 0 ;
2479
+ }
2480
+
2481
+ size_t numTrailingObjects (OverloadToken<GenericRequirementDescriptor>) const {
2482
+ return Flags.getNumConditionalRequirements ();
2483
+ }
2433
2484
};
2434
2485
using ProtocolConformanceDescriptor
2435
2486
= TargetProtocolConformanceDescriptor<InProcess>;
@@ -2441,14 +2492,6 @@ using TargetProtocolConformanceRecord =
2441
2492
2442
2493
using ProtocolConformanceRecord = TargetProtocolConformanceRecord<InProcess>;
2443
2494
2444
-
2445
- template <typename Runtime> struct TargetContextDescriptor ;
2446
-
2447
- template <typename Runtime>
2448
- using RelativeContextPointer =
2449
- RelativeIndirectablePointer<const TargetContextDescriptor<Runtime>,
2450
- /* nullable*/ true >;
2451
-
2452
2495
template <typename Runtime>
2453
2496
struct TargetGenericContext ;
2454
2497
@@ -2702,7 +2745,25 @@ class TargetGenericRequirementDescriptor {
2702
2745
assert (getKind () == GenericRequirementKind::Layout);
2703
2746
return Layout;
2704
2747
}
2748
+
2749
+ // / Determine whether this generic requirement has a known kind.
2750
+ // /
2751
+ // / \returns \c false for any future generic requirement kinds.
2752
+ bool hasKnownKind () const {
2753
+ switch (getKind ()) {
2754
+ case GenericRequirementKind::BaseClass:
2755
+ case GenericRequirementKind::Layout:
2756
+ case GenericRequirementKind::Protocol:
2757
+ case GenericRequirementKind::SameConformance:
2758
+ case GenericRequirementKind::SameType:
2759
+ return true ;
2760
+ }
2761
+
2762
+ return false ;
2763
+ }
2705
2764
};
2765
+ using GenericRequirementDescriptor =
2766
+ TargetGenericRequirementDescriptor<InProcess>;
2706
2767
2707
2768
// / CRTP class for a context descriptor that includes trailing generic
2708
2769
// / context description.
0 commit comments