Introduce a new declaration node, ParamDecl, for function parameters.

Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
This commit is contained in:
Doug Gregor
2014-04-20 05:23:35 +00:00
parent ef742f3cc0
commit 09797f7f99
20 changed files with 166 additions and 22 deletions

View File

@@ -954,6 +954,7 @@ static bool shouldSerializeMember(Decl *D) {
case DeclKind::Struct:
case DeclKind::Class:
case DeclKind::Var:
case DeclKind::Param:
case DeclKind::Func:
return true;
}
@@ -1673,6 +1674,27 @@ void Serializer::writeDecl(const Decl *D) {
break;
}
case DeclKind::Param: {
auto param = cast<ParamDecl>(D);
checkAllowedAttributes<
AK_unowned, AK_weak
>(param);
verifyAttrSerializable(param);
const Decl *DC = getDeclForContext(param->getDeclContext());
Type type = param->hasType() ? param->getType() : nullptr;
unsigned abbrCode = DeclTypeAbbrCodes[ParamLayout::Code];
ParamLayout::emitRecord(Out, ScratchRecord, abbrCode,
addIdentifierRef(param->getArgumentName()),
addIdentifierRef(param->getName()),
addDeclRef(DC),
param->isLet(),
addTypeRef(type),
addTypeRef(param->getInterfaceType()));
break;
}
case DeclKind::Func: {
auto fn = cast<FuncDecl>(D);
checkAllowedAttributes<
@@ -2421,6 +2443,7 @@ void Serializer::writeAllDeclsAndTypes() {
registerDeclTypeAbbr<StructLayout>();
registerDeclTypeAbbr<ConstructorLayout>();
registerDeclTypeAbbr<VarLayout>();
registerDeclTypeAbbr<ParamLayout>();
registerDeclTypeAbbr<FuncLayout>();
registerDeclTypeAbbr<PatternBindingLayout>();
registerDeclTypeAbbr<ProtocolLayout>();