-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenericOperationBodySyntax.cs
More file actions
99 lines (84 loc) · 3.37 KB
/
GenericOperationBodySyntax.cs
File metadata and controls
99 lines (84 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
namespace MLIR.Syntax;
/// <summary>
/// Represents the generic MLIR operation body syntax.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="GenericOperationBodySyntax"/> class.
/// </remarks>
/// <param name="operandList">The delimited operand list.</param>
/// <param name="successorList">The delimited successor list.</param>
/// <param name="regions">The regions nested under the operation.</param>
/// <param name="attributes">The delimited attribute dictionary.</param>
/// <param name="typeSignatureColonToken">The colon token that introduces the type signature, if present.</param>
/// <param name="typeSignatureSyntax">The trailing type signature syntax, if present.</param>
public sealed class GenericOperationBodySyntax(
DelimitedSyntaxList<SyntaxToken> operandList,
DelimitedSyntaxList<SyntaxToken> successorList,
IReadOnlyList<RegionSyntax> regions,
DelimitedSyntaxList<NamedAttributeSyntax> attributes,
SyntaxToken? typeSignatureColonToken,
TypeSyntax? typeSignatureSyntax) : OperationBodySyntax
{
/// <summary>
/// Gets the delimited operand list.
/// </summary>
public DelimitedSyntaxList<SyntaxToken> OperandList { get; } = operandList;
/// <summary>
/// Gets the delimited successor list.
/// </summary>
public DelimitedSyntaxList<SyntaxToken> SuccessorList { get; } = successorList;
/// <summary>
/// Gets the regions nested under the operation.
/// </summary>
public IReadOnlyList<RegionSyntax> Regions { get; } = regions;
/// <summary>
/// Gets the delimited attribute dictionary.
/// </summary>
public DelimitedSyntaxList<NamedAttributeSyntax> Attributes { get; } = attributes;
/// <summary>
/// Gets the colon token that introduces the type signature, if present.
/// </summary>
public SyntaxToken? TypeSignatureColonToken { get; } = typeSignatureColonToken;
/// <summary>
/// Gets the trailing type signature syntax, if present.
/// </summary>
public TypeSyntax? TypeSignatureSyntax { get; } = typeSignatureSyntax;
/// <summary>
/// Attempts to get the trailing type signature as raw syntax text.
/// </summary>
public bool TryGetRawTypeSignature(out RawSyntaxText? rawTypeSignature)
{
if (TypeSignatureSyntax != null)
{
return TypeSignatureSyntax.TryGetRawText(out rawTypeSignature);
}
rawTypeSignature = null;
return false;
}
/// <summary>
/// Gets the trailing type signature as raw syntax text.
/// </summary>
public RawSyntaxText? RawTypeSignature => TypeSignatureSyntax?.GetRawText();
/// <inheritdoc/>
public override bool TryGetGenericBody(out GenericOperationBodySyntax? genericBody)
{
genericBody = this;
return true;
}
/// <inheritdoc/>
public override void WriteTo(Text.SyntaxWriter writer, int indentLevel)
{
writer.WriteDelimitedList(OperandList, string.Empty);
writer.WriteDelimitedList(SuccessorList, " ");
foreach (var region in Regions)
{
writer.WriteRegion(region, indentLevel);
}
writer.WriteDelimitedList(Attributes, " ");
if (TypeSignatureColonToken != null && TypeSignatureSyntax != null)
{
writer.WriteToken(TypeSignatureColonToken.Value, " ");
TypeSignatureSyntax.WriteTo(writer, " ");
}
}
}