mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user