2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -2295,37 +2295,28 @@ struct TargetTypeMetadataRecord {
2295
2295
union {
2296
2296
// / A direct reference to a nominal type descriptor.
2297
2297
RelativeDirectPointerIntPair<TargetContextDescriptor<Runtime>,
2298
- TypeReferenceKind >
2298
+ TypeMetadataRecordKind >
2299
2299
DirectNominalTypeDescriptor;
2300
2300
2301
2301
// / An indirect reference to a nominal type descriptor.
2302
2302
RelativeDirectPointerIntPair<TargetSignedPointer<Runtime, TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor>,
2303
- TypeReferenceKind >
2303
+ TypeMetadataRecordKind >
2304
2304
IndirectNominalTypeDescriptor;
2305
-
2306
- // We only allow a subset of the TypeReferenceKinds here.
2307
- // Should we just acknowledge that this is a different enum?
2308
2305
};
2309
2306
2310
2307
public:
2311
- TypeReferenceKind getTypeKind () const {
2308
+ TypeMetadataRecordKind getTypeKind () const {
2312
2309
return DirectNominalTypeDescriptor.getInt ();
2313
2310
}
2314
2311
2315
2312
const TargetContextDescriptor<Runtime> *
2316
2313
getContextDescriptor () const {
2317
2314
switch (getTypeKind ()) {
2318
- case TypeReferenceKind ::DirectTypeDescriptor:
2315
+ case TypeMetadataRecordKind ::DirectTypeDescriptor:
2319
2316
return DirectNominalTypeDescriptor.getPointer ();
2320
2317
2321
- case TypeReferenceKind ::IndirectTypeDescriptor:
2318
+ case TypeMetadataRecordKind ::IndirectTypeDescriptor:
2322
2319
return *IndirectNominalTypeDescriptor.getPointer ();
2323
-
2324
- // These types (and any others we might add to TypeReferenceKind
2325
- // in the future) are just never used in these lists.
2326
- case TypeReferenceKind::DirectObjCClassName:
2327
- case TypeReferenceKind::IndirectObjCClass:
2328
- return nullptr ;
2329
2320
}
2330
2321
2331
2322
return nullptr ;
@@ -2415,6 +2406,9 @@ struct TargetTypeReference {
2415
2406
// / A direct reference to an Objective-C class name.
2416
2407
RelativeDirectPointer<const char >
2417
2408
DirectObjCClassName;
2409
+
2410
+ // / A "reference" to some metadata kind, e.g. tuple.
2411
+ MetadataKind MetadataKind;
2418
2412
};
2419
2413
2420
2414
const TargetContextDescriptor<Runtime> *
@@ -2428,12 +2422,18 @@ struct TargetTypeReference {
2428
2422
2429
2423
case TypeReferenceKind::DirectObjCClassName:
2430
2424
case TypeReferenceKind::IndirectObjCClass:
2425
+ case TypeReferenceKind::MetadataKind:
2431
2426
return nullptr ;
2432
2427
}
2433
2428
2434
2429
return nullptr ;
2435
2430
}
2436
2431
2432
+ enum MetadataKind getMetadataKind (TypeReferenceKind kind) const {
2433
+ assert (kind == TypeReferenceKind::MetadataKind);
2434
+ return MetadataKind;
2435
+ }
2436
+
2437
2437
#if SWIFT_OBJC_INTEROP
2438
2438
// / If this type reference is one of the kinds that supports ObjC
2439
2439
// / references,
@@ -2519,6 +2519,10 @@ struct TargetProtocolConformanceDescriptor final
2519
2519
return Flags.getTypeReferenceKind ();
2520
2520
}
2521
2521
2522
+ enum MetadataKind getMetadataKind () const {
2523
+ return TypeRef.getMetadataKind (getTypeKind ());
2524
+ }
2525
+
2522
2526
const char *getDirectObjCClassName () const {
2523
2527
return TypeRef.getDirectObjCClassName (getTypeKind ());
2524
2528
}
@@ -2546,6 +2550,11 @@ struct TargetProtocolConformanceDescriptor final
2546
2550
TargetRelativeContextPointer<Runtime>>();
2547
2551
}
2548
2552
2553
+ // / Whether this conformance is builtin by the compiler + runtime.
2554
+ bool isBuiltin () const {
2555
+ return getTypeKind () == TypeReferenceKind::MetadataKind;
2556
+ }
2557
+
2549
2558
// / Whether this conformance is non-unique because it has been synthesized
2550
2559
// / for a foreign type.
2551
2560
bool isSynthesizedNonUnique () const {
0 commit comments