mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[serialization] Lazily load top-level decls, extensions, and operators.
This switches from simple lists of decls to name-based on-disk hash tables, which allows decls to be loaded lazily when doing simple lookup (but not code completion, at least not yet). The on-disk hash table implementation is borrowed from Clang; eventually it will be pushed down to LLVM's Support library. (Fortunately the implementation is header-only.) This breaks a few tests that rely on magic protocols like IntegerLiteralConvertible, because the type checker won't have seen the types that conform to those protocols yet. This will be fixed by doing an additional "hey, modules, got any of these?" lookup. Swift SVN r7259
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#ifndef SWIFT_SERIALIZATION_MODULEFORMAT_H
|
||||
#define SWIFT_SERIALIZATION_MODULEFORMAT_H
|
||||
|
||||
#include "swift/AST/Decl.h"
|
||||
#include "swift/Serialization/BCRecordLayout.h"
|
||||
#include "llvm/Bitcode/BitCodes.h"
|
||||
|
||||
@@ -87,6 +88,20 @@ enum OperatorKind : uint8_t {
|
||||
static_assert(sizeof(OperatorKind) <= sizeof(TypeID),
|
||||
"too many operator kinds");
|
||||
|
||||
/// Translates an operator DeclKind to a fixity.
|
||||
static inline OperatorKind getRawStableFixity(DeclKind kind) {
|
||||
switch (kind) {
|
||||
case DeclKind::PrefixOperator:
|
||||
return Prefix;
|
||||
case DeclKind::PostfixOperator:
|
||||
return Postfix;
|
||||
case DeclKind::InfixOperator:
|
||||
return Infix;
|
||||
default:
|
||||
llvm_unreachable("unknown operator fixity");
|
||||
}
|
||||
}
|
||||
|
||||
// These IDs must \em not be renumbered or reordered without incrementing
|
||||
// VERSION_MAJOR.
|
||||
enum GenericRequirementKind : uint8_t {
|
||||
@@ -218,7 +233,7 @@ namespace input_block {
|
||||
namespace decls_block {
|
||||
// These IDs must \em not be renumbered or reordered without incrementing
|
||||
// VERSION_MAJOR.
|
||||
enum : uint8_t {
|
||||
enum RecordKind : uint8_t {
|
||||
NAME_ALIAS_TYPE = 1,
|
||||
NOMINAL_TYPE,
|
||||
PAREN_TYPE,
|
||||
@@ -730,7 +745,7 @@ namespace identifier_block {
|
||||
namespace index_block {
|
||||
// These IDs must \em not be renumbered or reordered without incrementing
|
||||
// VERSION_MAJOR.
|
||||
enum {
|
||||
enum RecordKind {
|
||||
TYPE_OFFSETS = 1,
|
||||
DECL_OFFSETS,
|
||||
IDENTIFIER_OFFSETS,
|
||||
@@ -745,7 +760,8 @@ namespace index_block {
|
||||
|
||||
using DeclListLayout = BCGenericRecordLayout<
|
||||
BCFixed<3>, // record ID
|
||||
BCArray<DeclIDField>
|
||||
BCVBR<16>, // table offset within the blob (see below)
|
||||
BCBlob // map from identifier strings to decl kinds / decl IDs
|
||||
>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user