Merge pull request #16268 from DougGregor/substitution-map-ast-adoption

[AST] Adopt SubstitutionMap as the storage mechanism for substitutions
This commit is contained in:
Doug Gregor
2018-04-30 20:36:02 -07:00
committed by GitHub
12 changed files with 323 additions and 118 deletions

View File

@@ -55,7 +55,7 @@ const uint16_t VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t VERSION_MINOR = 409; // Last change: standalone requirement subs
const uint16_t VERSION_MINOR = 410; // Last change: NameAlias substitution map
using DeclIDField = BCFixed<31>;
@@ -88,6 +88,11 @@ using GenericSignatureIDField = DeclIDField;
using GenericEnvironmentID = DeclID;
using GenericEnvironmentIDField = DeclIDField;
// SubstitutionMapID must be the same as DeclID because it is stored in the
// same way.
using SubstitutionMapID = DeclID;
using SubstitutionMapIDField = DeclIDField;
// ModuleID must be the same as IdentifierID because it is stored the same way.
using ModuleID = IdentifierID;
using ModuleIDField = IdentifierIDField;
@@ -644,10 +649,10 @@ namespace decls_block {
using NameAliasTypeLayout = BCRecordLayout<
NAME_ALIAS_TYPE,
DeclIDField, // typealias decl
TypeIDField, // parent type
TypeIDField // underlying type
// trailing substitutions
DeclIDField, // typealias decl
TypeIDField, // parent type
TypeIDField, // underlying type
SubstitutionMapIDField // substitution map
>;
using GenericTypeParamTypeLayout = BCRecordLayout<
@@ -1219,6 +1224,14 @@ namespace decls_block {
BCArray<TypeIDField> // generic parameter types
>;
using SubstitutionMapLayout = BCRecordLayout<
SUBSTITUTION_MAP,
GenericSignatureIDField, // generic signature
BCVBR<5>, // # of conformances
BCArray<TypeIDField> // replacement types
// Conformances trail the record.
>;
using SILGenericEnvironmentLayout = BCRecordLayout<
SIL_GENERIC_ENVIRONMENT,
BCArray<TypeIDField> // (generic parameter name, sugared interface
@@ -1594,7 +1607,8 @@ namespace index_block {
DECL_MEMBER_NAMES,
GENERIC_SIGNATURE_OFFSETS,
LastRecordKind = GENERIC_SIGNATURE_OFFSETS,
SUBSTITUTION_MAP_OFFSETS,
LastRecordKind = SUBSTITUTION_MAP_OFFSETS,
};
constexpr const unsigned RecordIDFieldWidth = 5;