mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[serialization] Add support for metatype types and constructor arguments.
Swift SVN r5744
This commit is contained in:
@@ -331,27 +331,24 @@ Decl *ModuleFile::getDecl(DeclID DID) {
|
||||
case decls_block::CONSTRUCTOR_DECL: {
|
||||
DeclID parentID;
|
||||
bool isImplicit;
|
||||
TypeID signatureID;
|
||||
DeclID implicitThisID;
|
||||
|
||||
decls_block::ConstructorLayout::readRecord(scratch, parentID, isImplicit,
|
||||
implicitThisID);
|
||||
signatureID, implicitThisID);
|
||||
Pattern *args = maybeReadPattern();
|
||||
assert(args && "missing arguments for constructor");
|
||||
|
||||
auto thisDecl = cast<VarDecl>(getDecl(implicitThisID));
|
||||
auto parent = cast<NominalTypeDecl>(getDeclContext(parentID));
|
||||
|
||||
auto emptyArgs = TuplePattern::create(ctx, SourceLoc(), {}, SourceLoc());
|
||||
auto ctor = new (ctx) ConstructorDecl(ctx.getIdentifier("constructor"),
|
||||
SourceLoc(), emptyArgs, thisDecl,
|
||||
SourceLoc(), args, thisDecl,
|
||||
/*generic params=*/nullptr,
|
||||
parent);
|
||||
declOrOffset = ctor;
|
||||
|
||||
// FIXME: Actually serialize the type instead of reconstructing it here.
|
||||
ctor->setType(FunctionType::get(MetaTypeType::get(thisDecl->getType(),
|
||||
ctx),
|
||||
FunctionType::get(ctx.TheEmptyTupleType,
|
||||
thisDecl->getType(),
|
||||
ctx),
|
||||
ctx));
|
||||
ctor->setType(getType(signatureID));
|
||||
|
||||
if (isImplicit)
|
||||
ctor->setImplicit();
|
||||
@@ -630,6 +627,13 @@ Type ModuleFile::getType(TypeID TID) {
|
||||
break;
|
||||
}
|
||||
|
||||
case decls_block::METATYPE_TYPE: {
|
||||
TypeID instanceID;
|
||||
decls_block::MetaTypeTypeLayout::readRecord(scratch, instanceID);
|
||||
typeOrOffset = MetaTypeType::get(getType(instanceID), ModuleContext->Ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// We don't know how to deserialize this kind of type.
|
||||
error();
|
||||
|
||||
Reference in New Issue
Block a user