Support the explicit representation of self-conformances.

Big, but actually NFC because we're never actually creating them.
This commit is contained in:
John McCall
2018-11-15 15:51:16 -05:00
parent 9cc9a94d56
commit 5553224fd4
41 changed files with 727 additions and 230 deletions

View File

@@ -29,11 +29,23 @@
using namespace swift;
static std::string mangleConstant(NormalProtocolConformance *C) {
static std::string mangleConstant(RootProtocolConformance *C) {
Mangle::ASTMangler Mangler;
return Mangler.mangleWitnessTable(C);
}
DeclContext *SILWitnessTable::getDeclContext() const {
return getConformance()->getDeclContext();
}
ProtocolDecl *SILWitnessTable::getProtocol() const {
return getConformance()->getProtocol();
}
CanType SILWitnessTable::getConformingType() const {
return getConformance()->getType()->getCanonicalType();
}
void SILWitnessTable::addWitnessTable() {
// Make sure we have not seen this witness table yet.
assert(Mod.WitnessTableMap.find(Conformance) ==
@@ -45,7 +57,7 @@ void SILWitnessTable::addWitnessTable() {
SILWitnessTable *SILWitnessTable::create(
SILModule &M, SILLinkage Linkage, IsSerialized_t Serialized,
NormalProtocolConformance *Conformance,
RootProtocolConformance *Conformance,
ArrayRef<SILWitnessTable::Entry> entries,
ArrayRef<ConditionalConformance> conditionalConformances) {
assert(Conformance && "Cannot create a witness table for a null "
@@ -68,7 +80,7 @@ SILWitnessTable *SILWitnessTable::create(
SILWitnessTable *
SILWitnessTable::create(SILModule &M, SILLinkage Linkage,
NormalProtocolConformance *Conformance) {
RootProtocolConformance *Conformance) {
assert(Conformance && "Cannot create a witness table for a null "
"conformance.");
@@ -89,7 +101,7 @@ SILWitnessTable::create(SILModule &M, SILLinkage Linkage,
SILWitnessTable::SILWitnessTable(
SILModule &M, SILLinkage Linkage, IsSerialized_t Serialized, StringRef N,
NormalProtocolConformance *Conformance, ArrayRef<Entry> entries,
RootProtocolConformance *Conformance, ArrayRef<Entry> entries,
ArrayRef<ConditionalConformance> conditionalConformances)
: Mod(M), Name(N), Linkage(Linkage), Conformance(Conformance), Entries(),
ConditionalConformances(), IsDeclaration(true), Serialized(false) {
@@ -97,7 +109,7 @@ SILWitnessTable::SILWitnessTable(
}
SILWitnessTable::SILWitnessTable(SILModule &M, SILLinkage Linkage, StringRef N,
NormalProtocolConformance *Conformance)
RootProtocolConformance *Conformance)
: Mod(M), Name(N), Linkage(Linkage), Conformance(Conformance), Entries(),
ConditionalConformances(), IsDeclaration(true), Serialized(false) {}
@@ -152,8 +164,9 @@ void SILWitnessTable::convertToDefinition(
}
bool SILWitnessTable::conformanceIsSerialized(
const NormalProtocolConformance *conformance) {
if (conformance->isResilient())
const RootProtocolConformance *conformance) {
auto normalConformance = dyn_cast<NormalProtocolConformance>(conformance);
if (normalConformance && normalConformance->isResilient())
return false;
// Serialize witness tables for conformances synthesized by