[serialization] Add support for generic functions.

This currently does a little dance to handle PolymorphicFunctionTypes.
These are currently implemented by referencing the GenericParamList of
an actual polymorphic function, so they can't be deserialized without
knowing which function they are attached to. To solve this,
PolymorphicFunctionTypes are serialized as regular FunctionTypes. Then,
when a generic function decl is being deserialized, it will rebuild
a PolymorphicFunctionType from the serialized type and its own generic
parameter list.

Requirements on the generic types are coming next.

Swift SVN r5983
This commit is contained in:
Jordan Rose
2013-07-04 00:14:23 +00:00
parent e662ec5bf8
commit 61efdb5ff7
5 changed files with 193 additions and 37 deletions

View File

@@ -211,6 +211,10 @@ namespace decls_block {
NOMINAL_TYPE_PATTERN,
VAR_PATTERN,
GENERIC_PARAM_LIST = 240,
GENERIC_PARAM,
GENERIC_REQUIREMENT,
XREF = 254,
DECL_CONTEXT = 255
};
@@ -338,6 +342,8 @@ namespace decls_block {
BCFixed<1>, // class method
DeclIDField, // associated decl (for get/set or operators)
DeclIDField // overridden function
// The record is trailed by its generic parameters, if any, followed by its
// argument and body parameter patterns.
>;
using PatternBindingLayout = BCRecordLayout<
@@ -407,6 +413,18 @@ namespace decls_block {
// The sub-pattern trails the record.
>;
using GenericParamListLayout = BCRecordLayout<
GENERIC_PARAM_LIST,
BCArray<TypeIDField> // Archetypes
// The actual parameters and requirements trail the record.
>;
using GenericParamLayout = BCRecordLayout<
GENERIC_PARAM,
DeclIDField // Typealias
>;
using XRefLayout = BCRecordLayout<
XREF,
XRefKindField, // reference kind