347 lines
14 KiB
C#
347 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.CodeAnalysis.Syntax.InternalSyntax;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
internal sealed class LocalFunctionStatementSyntax : StatementSyntax
|
|
{
|
|
internal readonly GreenNode? attributeLists;
|
|
|
|
internal readonly GreenNode? modifiers;
|
|
|
|
internal readonly TypeSyntax returnType;
|
|
|
|
internal readonly SyntaxToken identifier;
|
|
|
|
internal readonly TypeParameterListSyntax? typeParameterList;
|
|
|
|
internal readonly ParameterListSyntax parameterList;
|
|
|
|
internal readonly GreenNode? constraintClauses;
|
|
|
|
internal readonly BlockSyntax? body;
|
|
|
|
internal readonly ArrowExpressionClauseSyntax? expressionBody;
|
|
|
|
internal readonly SyntaxToken? semicolonToken;
|
|
|
|
public override SyntaxList<AttributeListSyntax> AttributeLists => new SyntaxList<AttributeListSyntax>(attributeLists);
|
|
|
|
public SyntaxList<SyntaxToken> Modifiers => new SyntaxList<SyntaxToken>(modifiers);
|
|
|
|
public TypeSyntax ReturnType => returnType;
|
|
|
|
public SyntaxToken Identifier => identifier;
|
|
|
|
public TypeParameterListSyntax? TypeParameterList => typeParameterList;
|
|
|
|
public ParameterListSyntax ParameterList => parameterList;
|
|
|
|
public SyntaxList<TypeParameterConstraintClauseSyntax> ConstraintClauses => new SyntaxList<TypeParameterConstraintClauseSyntax>(constraintClauses);
|
|
|
|
public BlockSyntax? Body => body;
|
|
|
|
public ArrowExpressionClauseSyntax? ExpressionBody => expressionBody;
|
|
|
|
public SyntaxToken? SemicolonToken => semicolonToken;
|
|
|
|
internal LocalFunctionStatementSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, GreenNode? constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations)
|
|
: base(kind, diagnostics, annotations)
|
|
{
|
|
((GreenNode)this).SlotCount = 10;
|
|
if (attributeLists != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
|
this.attributeLists = attributeLists;
|
|
}
|
|
if (modifiers != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(modifiers);
|
|
this.modifiers = modifiers;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)returnType);
|
|
this.returnType = returnType;
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)identifier);
|
|
this.identifier = identifier;
|
|
if (typeParameterList != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)typeParameterList);
|
|
this.typeParameterList = typeParameterList;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)parameterList);
|
|
this.parameterList = parameterList;
|
|
if (constraintClauses != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(constraintClauses);
|
|
this.constraintClauses = constraintClauses;
|
|
}
|
|
if (body != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)body);
|
|
this.body = body;
|
|
}
|
|
if (expressionBody != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)expressionBody);
|
|
this.expressionBody = expressionBody;
|
|
}
|
|
if (semicolonToken != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)semicolonToken);
|
|
this.semicolonToken = semicolonToken;
|
|
}
|
|
}
|
|
|
|
internal LocalFunctionStatementSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, GreenNode? constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, SyntaxFactoryContext context)
|
|
: base(kind)
|
|
{
|
|
SetFactoryContext(context);
|
|
((GreenNode)this).SlotCount = 10;
|
|
if (attributeLists != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
|
this.attributeLists = attributeLists;
|
|
}
|
|
if (modifiers != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(modifiers);
|
|
this.modifiers = modifiers;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)returnType);
|
|
this.returnType = returnType;
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)identifier);
|
|
this.identifier = identifier;
|
|
if (typeParameterList != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)typeParameterList);
|
|
this.typeParameterList = typeParameterList;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)parameterList);
|
|
this.parameterList = parameterList;
|
|
if (constraintClauses != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(constraintClauses);
|
|
this.constraintClauses = constraintClauses;
|
|
}
|
|
if (body != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)body);
|
|
this.body = body;
|
|
}
|
|
if (expressionBody != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)expressionBody);
|
|
this.expressionBody = expressionBody;
|
|
}
|
|
if (semicolonToken != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)semicolonToken);
|
|
this.semicolonToken = semicolonToken;
|
|
}
|
|
}
|
|
|
|
internal LocalFunctionStatementSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, GreenNode? constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken)
|
|
: base(kind)
|
|
{
|
|
((GreenNode)this).SlotCount = 10;
|
|
if (attributeLists != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(attributeLists);
|
|
this.attributeLists = attributeLists;
|
|
}
|
|
if (modifiers != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(modifiers);
|
|
this.modifiers = modifiers;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)returnType);
|
|
this.returnType = returnType;
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)identifier);
|
|
this.identifier = identifier;
|
|
if (typeParameterList != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)typeParameterList);
|
|
this.typeParameterList = typeParameterList;
|
|
}
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)parameterList);
|
|
this.parameterList = parameterList;
|
|
if (constraintClauses != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(constraintClauses);
|
|
this.constraintClauses = constraintClauses;
|
|
}
|
|
if (body != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)body);
|
|
this.body = body;
|
|
}
|
|
if (expressionBody != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)expressionBody);
|
|
this.expressionBody = expressionBody;
|
|
}
|
|
if (semicolonToken != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)semicolonToken);
|
|
this.semicolonToken = semicolonToken;
|
|
}
|
|
}
|
|
|
|
internal override GreenNode? GetSlot(int index)
|
|
{
|
|
return (GreenNode?)(index switch
|
|
{
|
|
0 => attributeLists,
|
|
1 => modifiers,
|
|
2 => returnType,
|
|
3 => identifier,
|
|
4 => typeParameterList,
|
|
5 => parameterList,
|
|
6 => constraintClauses,
|
|
7 => body,
|
|
8 => expressionBody,
|
|
9 => semicolonToken,
|
|
_ => null,
|
|
});
|
|
}
|
|
|
|
internal override SyntaxNode CreateRed(SyntaxNode? parent, int position)
|
|
{
|
|
return (SyntaxNode)(object)new Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax(this, parent, position);
|
|
}
|
|
|
|
public override void Accept(CSharpSyntaxVisitor visitor)
|
|
{
|
|
visitor.VisitLocalFunctionStatement(this);
|
|
}
|
|
|
|
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitLocalFunctionStatement(this);
|
|
}
|
|
|
|
public LocalFunctionStatementSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxList<SyntaxToken> modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
|
if (attributeLists != AttributeLists || modifiers != Modifiers || returnType != ReturnType || identifier != Identifier || typeParameterList != TypeParameterList || parameterList != ParameterList || constraintClauses != ConstraintClauses || body != Body || expressionBody != ExpressionBody || semicolonToken != SemicolonToken)
|
|
{
|
|
LocalFunctionStatementSyntax localFunctionStatementSyntax = SyntaxFactory.LocalFunctionStatement(attributeLists, modifiers, returnType, identifier, typeParameterList, parameterList, constraintClauses, body, expressionBody, semicolonToken);
|
|
DiagnosticInfo[] diagnostics = ((GreenNode)this).GetDiagnostics();
|
|
if (diagnostics != null && diagnostics.Length != 0)
|
|
{
|
|
localFunctionStatementSyntax = GreenNodeExtensions.WithDiagnosticsGreen<LocalFunctionStatementSyntax>(localFunctionStatementSyntax, diagnostics);
|
|
}
|
|
SyntaxAnnotation[] annotations = ((GreenNode)this).GetAnnotations();
|
|
if (annotations != null && annotations.Length != 0)
|
|
{
|
|
localFunctionStatementSyntax = GreenNodeExtensions.WithAnnotationsGreen<LocalFunctionStatementSyntax>(localFunctionStatementSyntax, (IEnumerable<SyntaxAnnotation>)annotations);
|
|
}
|
|
return localFunctionStatementSyntax;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics)
|
|
{
|
|
return (GreenNode)(object)new LocalFunctionStatementSyntax(base.Kind, attributeLists, modifiers, returnType, identifier, typeParameterList, parameterList, constraintClauses, body, expressionBody, semicolonToken, diagnostics, ((GreenNode)this).GetAnnotations());
|
|
}
|
|
|
|
internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations)
|
|
{
|
|
return (GreenNode)(object)new LocalFunctionStatementSyntax(base.Kind, attributeLists, modifiers, returnType, identifier, typeParameterList, parameterList, constraintClauses, body, expressionBody, semicolonToken, ((GreenNode)this).GetDiagnostics(), annotations);
|
|
}
|
|
|
|
internal LocalFunctionStatementSyntax(ObjectReader reader)
|
|
: base(reader)
|
|
{
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001b: Expected O, but got Unknown
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0038: Expected O, but got Unknown
|
|
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c8: Expected O, but got Unknown
|
|
((GreenNode)this).SlotCount = 10;
|
|
GreenNode val = (GreenNode)reader.ReadValue();
|
|
if (val != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(val);
|
|
attributeLists = val;
|
|
}
|
|
GreenNode val2 = (GreenNode)reader.ReadValue();
|
|
if (val2 != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(val2);
|
|
modifiers = val2;
|
|
}
|
|
TypeSyntax typeSyntax = (TypeSyntax)reader.ReadValue();
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)typeSyntax);
|
|
returnType = typeSyntax;
|
|
SyntaxToken syntaxToken = (SyntaxToken)reader.ReadValue();
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken);
|
|
identifier = syntaxToken;
|
|
TypeParameterListSyntax typeParameterListSyntax = (TypeParameterListSyntax)reader.ReadValue();
|
|
if (typeParameterListSyntax != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)typeParameterListSyntax);
|
|
typeParameterList = typeParameterListSyntax;
|
|
}
|
|
ParameterListSyntax parameterListSyntax = (ParameterListSyntax)reader.ReadValue();
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)parameterListSyntax);
|
|
parameterList = parameterListSyntax;
|
|
GreenNode val3 = (GreenNode)reader.ReadValue();
|
|
if (val3 != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth(val3);
|
|
constraintClauses = val3;
|
|
}
|
|
BlockSyntax blockSyntax = (BlockSyntax)reader.ReadValue();
|
|
if (blockSyntax != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)blockSyntax);
|
|
body = blockSyntax;
|
|
}
|
|
ArrowExpressionClauseSyntax arrowExpressionClauseSyntax = (ArrowExpressionClauseSyntax)reader.ReadValue();
|
|
if (arrowExpressionClauseSyntax != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)arrowExpressionClauseSyntax);
|
|
expressionBody = arrowExpressionClauseSyntax;
|
|
}
|
|
SyntaxToken syntaxToken2 = (SyntaxToken)reader.ReadValue();
|
|
if (syntaxToken2 != null)
|
|
{
|
|
((GreenNode)this).AdjustFlagsAndWidth((GreenNode)(object)syntaxToken2);
|
|
semicolonToken = syntaxToken2;
|
|
}
|
|
}
|
|
|
|
internal override void WriteTo(ObjectWriter writer)
|
|
{
|
|
((GreenNode)this).WriteTo(writer);
|
|
writer.WriteValue((IObjectWritable)(object)attributeLists);
|
|
writer.WriteValue((IObjectWritable)(object)modifiers);
|
|
writer.WriteValue((IObjectWritable)(object)returnType);
|
|
writer.WriteValue((IObjectWritable)(object)identifier);
|
|
writer.WriteValue((IObjectWritable)(object)typeParameterList);
|
|
writer.WriteValue((IObjectWritable)(object)parameterList);
|
|
writer.WriteValue((IObjectWritable)(object)constraintClauses);
|
|
writer.WriteValue((IObjectWritable)(object)body);
|
|
writer.WriteValue((IObjectWritable)(object)expressionBody);
|
|
writer.WriteValue((IObjectWritable)(object)semicolonToken);
|
|
}
|
|
|
|
static LocalFunctionStatementSyntax()
|
|
{
|
|
ObjectBinder.RegisterTypeReader(typeof(LocalFunctionStatementSyntax), (Func<ObjectReader, IObjectWritable>)((ObjectReader r) => (IObjectWritable)(object)new LocalFunctionStatementSyntax(r)));
|
|
}
|
|
}
|