|
20 | 20 | #define SWIFT_ABI_METADATAVALUES_H |
21 | 21 |
|
22 | 22 | #include "swift/ABI/KeyPath.h" |
| 23 | +#include "swift/ABI/ProtocolDispatchStrategy.h" |
23 | 24 | #include "swift/AST/Ownership.h" |
24 | 25 | #include "swift/Basic/LLVM.h" |
25 | 26 | #include "swift/Basic/FlagSet.h" |
26 | | -#include "swift/Runtime/Unreachable.h" |
27 | 27 |
|
28 | 28 | #include <stdlib.h> |
29 | 29 | #include <stdint.h> |
@@ -410,20 +410,6 @@ enum class SpecialProtocol: uint8_t { |
410 | 410 | Error = 1, |
411 | 411 | }; |
412 | 412 |
|
413 | | -/// Identifiers for protocol method dispatch strategies. |
414 | | -enum class ProtocolDispatchStrategy: uint8_t { |
415 | | - /// Uses ObjC method dispatch. |
416 | | - /// |
417 | | - /// This must be 0 for ABI compatibility with Objective-C protocol_t records. |
418 | | - ObjC = 0, |
419 | | - |
420 | | - /// Uses Swift protocol witness table dispatch. |
421 | | - /// |
422 | | - /// To invoke methods of this protocol, a pointer to a protocol witness table |
423 | | - /// corresponding to the protocol conformance must be available. |
424 | | - Swift = 1, |
425 | | -}; |
426 | | - |
427 | 413 | /// Flags for protocol descriptors. |
428 | 414 | class ProtocolDescriptorFlags { |
429 | 415 | typedef uint32_t int_type; |
@@ -486,18 +472,7 @@ class ProtocolDescriptorFlags { |
486 | 472 |
|
487 | 473 | /// Does the protocol require a witness table for method dispatch? |
488 | 474 | bool needsWitnessTable() const { |
489 | | - return needsWitnessTable(getDispatchStrategy()); |
490 | | - } |
491 | | - |
492 | | - static bool needsWitnessTable(ProtocolDispatchStrategy strategy) { |
493 | | - switch (strategy) { |
494 | | - case ProtocolDispatchStrategy::ObjC: |
495 | | - return false; |
496 | | - case ProtocolDispatchStrategy::Swift: |
497 | | - return true; |
498 | | - } |
499 | | - |
500 | | - swift_runtime_unreachable("Unhandled ProtocolDispatchStrategy in switch."); |
| 475 | + return swift::protocolRequiresWitnessTable(getDispatchStrategy()); |
501 | 476 | } |
502 | 477 |
|
503 | 478 | /// Return the identifier if this is a special runtime-known protocol. |
|
0 commit comments