Skip to content

Commit b1aa23a

Browse files
committed
[Serialization] Allow clients to deserialize all generic signatures.
As a debugging aid, allow clients to deserialize all generic signatures in a given module file.
1 parent 82e1c98 commit b1aa23a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

include/swift/AST/Module.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,15 @@ class LoadedFile : public FileUnit {
11731173

11741174
virtual bool isSystemModule() const { return false; }
11751175

1176+
/// Retrieve the set of generic signatures stored within this module.
1177+
///
1178+
/// \returns \c true if this module file supports retrieving all of the
1179+
/// generic signatures, \c false otherwise.
1180+
virtual bool getAllGenericSignatures(
1181+
SmallVectorImpl<GenericSignature*> &genericSignatures) {
1182+
return false;
1183+
}
1184+
11761185
static bool classof(const FileUnit *file) {
11771186
return file->getKind() == FileUnitKind::SerializedAST ||
11781187
file->getKind() == FileUnitKind::ClangModule;

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ class SerializedASTFile final : public LoadedFile {
195195

196196
virtual const clang::Module *getUnderlyingClangModule() const override;
197197

198+
virtual bool getAllGenericSignatures(
199+
SmallVectorImpl<GenericSignature*> &genericSignatures)
200+
override;
201+
198202
static bool classof(const FileUnit *file) {
199203
return file->getKind() == FileUnitKind::SerializedAST;
200204
}

lib/Serialization/ModuleFile.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,17 @@ bool SerializedASTFile::hasEntryPoint() const {
21752175
return File.Bits.HasEntryPoint;
21762176
}
21772177

2178+
bool SerializedASTFile::getAllGenericSignatures(
2179+
SmallVectorImpl<GenericSignature*> &genericSignatures) {
2180+
genericSignatures.clear();
2181+
for (unsigned index : indices(File.GenericSignatures)) {
2182+
if (auto genericSig = File.getGenericSignature(index + 1))
2183+
genericSignatures.push_back(genericSig);
2184+
}
2185+
2186+
return true;
2187+
}
2188+
21782189
ClassDecl *SerializedASTFile::getMainClass() const {
21792190
assert(hasEntryPoint());
21802191
return cast_or_null<ClassDecl>(File.getDecl(File.Bits.EntryPointDeclID));

0 commit comments

Comments
 (0)