mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Only record conformances to known protocols, and include them in modules.
This is really two commits in one: first, change the AST and TypeChecker to only track conformances to known protocols, and second, make sure we can deserialize decls that conform to known protocols on demand. The latter is necessary for the type checker to solve constraint systems that are not fully constrained, and also requires tracking decls with conversion methods. Currently decls conforming to known protocols are eagerly deserialized; that will change soon to be a new ModuleLoader callback. Decls with conversion functions will continue to be eagerly deserialized for the near future. This fixes the initial regressions in making decl deserialization lazy. Swift SVN r7264
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "ModuleFormat.h"
|
||||
#include "swift/AST/Decl.h"
|
||||
#include "swift/AST/Identifier.h"
|
||||
#include "swift/AST/KnownProtocols.h"
|
||||
#include "swift/AST/Module.h"
|
||||
#include "swift/AST/TypeLoc.h"
|
||||
#include "swift/Serialization/SerializedModuleLoader.h"
|
||||
@@ -176,10 +177,14 @@ private:
|
||||
std::unique_ptr<SerializedDeclTable> OperatorDecls;
|
||||
std::unique_ptr<SerializedDeclTable> ExtensionDecls;
|
||||
|
||||
/// Read an on-disk decl hash table stored in index_block::DeclListLayout
|
||||
/// format.
|
||||
std::unique_ptr<SerializedDeclTable>
|
||||
readDeclTable(ArrayRef<uint64_t> fields, StringRef blobData);
|
||||
using ProtocolAdopterVec = SmallVector<serialization::DeclID, 4>;
|
||||
|
||||
/// All adopters of compiler-known protocols in this module.
|
||||
///
|
||||
/// These are eagerly deserialized to aid in type-checking.
|
||||
/// The final entry (at NumKnownProtocols) contains decls that have
|
||||
/// conversion methods, which also need to be eagerly deserialized.
|
||||
ProtocolAdopterVec KnownProtocolAdopters[NumKnownProtocols+1];
|
||||
|
||||
/// Whether this module file can be used.
|
||||
ModuleStatus Status;
|
||||
@@ -194,6 +199,19 @@ private:
|
||||
Status = issue;
|
||||
}
|
||||
|
||||
/// Read an on-disk decl hash table stored in index_block::DeclListLayout
|
||||
/// format.
|
||||
std::unique_ptr<SerializedDeclTable>
|
||||
readDeclTable(ArrayRef<uint64_t> fields, StringRef blobData);
|
||||
|
||||
/// Reads the known protocols block.
|
||||
bool readKnownProtocolsBlock(llvm::BitstreamCursor &cursor);
|
||||
|
||||
/// Reads the index block, which contains global tables.
|
||||
///
|
||||
/// Returns false if there was an error.
|
||||
bool readIndexBlock(llvm::BitstreamCursor &cursor);
|
||||
|
||||
/// Recursively reads a pattern from \c DeclTypeCursor.
|
||||
///
|
||||
/// If the record at the cursor is not a pattern, returns null.
|
||||
|
||||
Reference in New Issue
Block a user