[serialization] Add support for subscript decls.

For consistency purposes, VarDecls in the subscript pattern now have the
enclosing nominal as their decl context, rather than no decl context at all.

Swift SVN r6177
This commit is contained in:
Jordan Rose
2013-07-11 21:22:08 +00:00
parent 40a8694ef0
commit 0afaa86bcc
4 changed files with 94 additions and 3 deletions

View File

@@ -975,6 +975,41 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
break;
}
case decls_block::SUBSCRIPT_DECL: {
DeclID contextID;
bool isImplicit;
TypeID declTypeID, elemTypeID;
DeclID getterID, setterID;
DeclID overriddenID;
decls_block::SubscriptLayout::readRecord(scratch, contextID, isImplicit,
declTypeID, elemTypeID,
getterID, setterID,
overriddenID);
Pattern *indices = maybeReadPattern();
assert(indices);
auto elemTy = TypeLoc::withoutLoc(getType(elemTypeID));
auto getter = cast_or_null<FuncDecl>(getDecl(getterID));
auto setter = cast_or_null<FuncDecl>(getDecl(setterID));
auto subscript = new (ctx) SubscriptDecl(ctx.getIdentifier("__subscript"),
SourceLoc(), indices, SourceLoc(),
elemTy, SourceRange(),
getter, setter,
getDeclContext(contextID));
declOrOffset = subscript;
subscript->setType(getType(declTypeID));
if (isImplicit)
subscript->setImplicit();
auto overriddenDecl = cast_or_null<SubscriptDecl>(getDecl(overriddenID));
subscript->setOverriddenDecl(overriddenDecl);
break;
}
case decls_block::XREF: {
uint8_t kind;
TypeID expectedTypeID;