mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add Self- and SelfWitnessTable metadata sources to capture descriptors
These can show up in partial applications of functions with the witness_method calling convention.
This commit is contained in:
@@ -182,6 +182,9 @@ class MetadataSource {
|
||||
return decodeGenericArgument(A, it, end);
|
||||
case 'P':
|
||||
return decodeParent(A, it, end);
|
||||
case 'S':
|
||||
++it;
|
||||
return A.template createSelf();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@@ -315,6 +318,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// Metadata gotten through the parent of a nominal type's metadata.
|
||||
class ParentMetadataSource final : public MetadataSource {
|
||||
const MetadataSource *Child;
|
||||
public:
|
||||
@@ -337,6 +341,41 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// A source of metadata from the Self metadata parameter passed via
|
||||
/// a witness_method convention function.
|
||||
class SelfMetadataSource final : public MetadataSource {
|
||||
public:
|
||||
SelfMetadataSource() : MetadataSource(MetadataSourceKind::Self) {}
|
||||
|
||||
template <typename Allocator>
|
||||
static const SelfMetadataSource*
|
||||
create(Allocator &A) {
|
||||
return A.template make_source<SelfMetadataSource>();
|
||||
}
|
||||
|
||||
static bool classof(const MetadataSource *MS) {
|
||||
return MS->getKind() == MetadataSourceKind::Self;
|
||||
}
|
||||
};
|
||||
|
||||
/// A source of metadata from the Self witness table parameter passed via
|
||||
/// a witness_method convention function.
|
||||
class SelfWitnessTableMetadataSource final : public MetadataSource {
|
||||
public:
|
||||
SelfWitnessTableMetadataSource()
|
||||
: MetadataSource(MetadataSourceKind::SelfWitnessTable) {}
|
||||
|
||||
template <typename Allocator>
|
||||
static const SelfWitnessTableMetadataSource*
|
||||
create(Allocator &A) {
|
||||
return A.template make_source<SelfWitnessTableMetadataSource>();
|
||||
}
|
||||
|
||||
static bool classof(const MetadataSource *MS) {
|
||||
return MS->getKind() == MetadataSourceKind::SelfWitnessTable;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ImplClass, typename RetTy = void, typename... Args>
|
||||
class MetadataSourceVisitor {
|
||||
public:
|
||||
|
||||
@@ -62,6 +62,16 @@ public:
|
||||
createParent(const MetadataSource *Child) {
|
||||
return ParentMetadataSource::create(*this, Child);
|
||||
}
|
||||
|
||||
const SelfMetadataSource *
|
||||
createSelf() {
|
||||
return SelfMetadataSource::create(*this);
|
||||
}
|
||||
|
||||
const SelfWitnessTableMetadataSource *
|
||||
createSelfWitnessTable() {
|
||||
return SelfWitnessTableMetadataSource::create(*this);
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace reflection
|
||||
|
||||
@@ -21,3 +21,5 @@ METADATA_SOURCE(ReferenceCapture, MetadataSource)
|
||||
METADATA_SOURCE(MetadataCapture, MetadataSource)
|
||||
METADATA_SOURCE(GenericArgument, MetadataSource)
|
||||
METADATA_SOURCE(Parent, MetadataSource)
|
||||
METADATA_SOURCE(Self, MetadataSource)
|
||||
METADATA_SOURCE(SelfWitnessTable, MetadataSource)
|
||||
|
||||
Reference in New Issue
Block a user