Browse Source

Merge 19cac08535 into fccd9e2b76

pull/3523/merge
Siegfried Pammer 8 months ago committed by GitHub
parent
commit
9307df2889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      Directory.Packages.props
  2. 384
      ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs
  3. 16
      ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj
  4. 3
      ICSharpCode.Decompiler.Generators/IsExternalInit.cs
  5. 32
      ICSharpCode.Decompiler.Generators/RoslynHelpers.cs
  6. 125
      ICSharpCode.Decompiler.Generators/TreeTraversal.cs
  7. 88
      ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
  8. 94
      ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs
  9. 3
      ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs
  10. 52
      ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs
  11. 36
      ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs
  12. 18
      ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs
  13. 25
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs
  14. 24
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs
  15. 28
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs
  16. 132
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs
  17. 26
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs
  18. 26
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs
  19. 25
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs
  20. 25
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs
  21. 26
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs
  22. 25
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs
  23. 26
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs
  24. 27
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs
  25. 30
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DecompilerAstNodeAttribute.cs
  26. 24
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs
  27. 24
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs
  28. 31
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs
  29. 83
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs
  30. 24
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs
  31. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs
  32. 94
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
  33. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs
  34. 21
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs
  35. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs
  36. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs
  37. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs
  38. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs
  39. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs
  40. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs
  41. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs
  42. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs
  43. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs
  44. 20
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs
  45. 213
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs
  46. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/RecursivePatternExpression.cs
  47. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SizeOfExpression.cs
  48. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/StackAllocExpression.cs
  49. 36
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SwitchExpression.cs
  50. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThisReferenceExpression.cs
  51. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThrowExpression.cs
  52. 20
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TupleExpression.cs
  53. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeOfExpression.cs
  54. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeReferenceExpression.cs
  55. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs
  56. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UncheckedExpression.cs
  57. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UndocumentedExpression.cs
  58. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/WithInitializerExpression.cs
  59. 18
      ICSharpCode.Decompiler/CSharp/Syntax/FunctionPointerAstType.cs
  60. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Attribute.cs
  61. 64
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/AttributeSection.cs
  62. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs
  63. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Constraint.cs
  64. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs
  65. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/ExternAliasDeclaration.cs
  66. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/NamespaceDeclaration.cs
  67. 24
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/PreProcessorDirective.cs
  68. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs
  69. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs
  70. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingAliasDeclaration.cs
  71. 18
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingDeclaration.cs
  72. 468
      ICSharpCode.Decompiler/CSharp/Syntax/IAstVisitor.cs
  73. 48
      ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs
  74. 20
      ICSharpCode.Decompiler/CSharp/Syntax/InvocationAstType.cs
  75. 18
      ICSharpCode.Decompiler/CSharp/Syntax/MemberType.cs
  76. 10
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/IdentifierExpressionBackreference.cs
  77. 18
      ICSharpCode.Decompiler/CSharp/Syntax/PrimitiveType.cs
  78. 9
      ICSharpCode.Decompiler/CSharp/Syntax/Role.cs
  79. 56
      ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs
  80. 96
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs
  81. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/BreakStatement.cs
  82. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/CheckedStatement.cs
  83. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ContinueStatement.cs
  84. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/DoWhileStatement.cs
  85. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/EmptyStatement.cs
  86. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ExpressionStatement.cs
  87. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/FixedStatement.cs
  88. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForStatement.cs
  89. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForeachStatement.cs
  90. 54
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/GotoStatement.cs
  91. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/IfElseStatement.cs
  92. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/LabelStatement.cs
  93. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/LocalFunctionDeclarationStatement.cs
  94. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/LockStatement.cs
  95. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ReturnStatement.cs
  96. 82
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs
  97. 100
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/SwitchStatement.cs
  98. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ThrowStatement.cs
  99. 115
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs
  100. 18
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/UncheckedStatement.cs
  101. Some files were not shown because too many files have changed in this diff Show More

3
Directory.Packages.props

@ -14,8 +14,11 @@ @@ -14,8 +14,11 @@
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageVersion Include="McMaster.Extensions.Hosting.CommandLine" Version="4.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.14.0" />
<PackageVersion Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta2-22171-02" />
<PackageVersion Include="Microsoft.DiaSymReader" Version="1.4.0" />
<PackageVersion Include="Microsoft.DiaSymReader.Native" Version="17.0.0-beta1.21524.1" />

384
ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs

@ -0,0 +1,384 @@ @@ -0,0 +1,384 @@
using System.Collections;
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace ICSharpCode.Decompiler.Generators;
[Generator]
internal class DecompilerSyntaxTreeGenerator : IIncrementalGenerator
{
record AstNodeAdditions(string NodeName, bool NeedsAcceptImpls, bool NeedsVisitor, bool NeedsNullNode, bool NeedsPatternPlaceholder, int NullNodeBaseCtorParamCount, bool IsTypeNode, string VisitMethodName, string VisitMethodParamType, EquatableArray<(string Member, string TypeName, bool RecursiveMatch, bool MatchAny)>? MembersToMatch);
AstNodeAdditions GetAstNodeAdditions(GeneratorAttributeSyntaxContext context, CancellationToken ct)
{
var targetSymbol = (INamedTypeSymbol)context.TargetSymbol;
var attribute = context.Attributes.SingleOrDefault(ad => ad.AttributeClass?.Name == "DecompilerAstNodeAttribute")!;
var (visitMethodName, paramTypeName) = targetSymbol.Name switch {
"ErrorExpression" => ("ErrorNode", "AstNode"),
string s when s.Contains("AstType") => (s.Replace("AstType", "Type"), s),
_ => (targetSymbol.Name, targetSymbol.Name),
};
List<(string Member, string TypeName, bool RecursiveMatch, bool MatchAny)>? membersToMatch = null;
if (!targetSymbol.MemberNames.Contains("DoMatch"))
{
membersToMatch = new();
var astNodeType = (INamedTypeSymbol)context.SemanticModel.GetSpeculativeSymbolInfo(context.TargetNode.Span.Start, SyntaxFactory.ParseTypeName("AstNode"), SpeculativeBindingOption.BindAsTypeOrNamespace).Symbol!;
if (targetSymbol.BaseType!.MemberNames.Contains("MatchAttributesAndModifiers"))
membersToMatch.Add(("MatchAttributesAndModifiers", null!, false, false));
foreach (var m in targetSymbol.GetMembers())
{
if (m is not IPropertySymbol property || property.IsIndexer || property.IsOverride)
continue;
if (property.GetAttributes().Any(a => a.AttributeClass?.Name == "ExcludeFromMatchAttribute"))
continue;
if (property.Type.MetadataName is "CSharpTokenNode" or "TextLocation")
continue;
switch (property.Type)
{
case INamedTypeSymbol named when named.IsDerivedFrom(astNodeType) || named.MetadataName == "AstNodeCollection`1":
membersToMatch.Add((property.Name, named.Name, true, false));
break;
case INamedTypeSymbol { TypeKind: TypeKind.Enum } named when named.GetMembers().Any(_ => _.Name == "Any"):
membersToMatch.Add((property.Name, named.Name, false, true));
break;
default:
membersToMatch.Add((property.Name, property.Type.Name, false, false));
break;
}
}
}
return new(targetSymbol.Name, !targetSymbol.MemberNames.Contains("AcceptVisitor"),
NeedsVisitor: !targetSymbol.IsAbstract && targetSymbol.BaseType!.IsAbstract,
NeedsNullNode: (bool)attribute.ConstructorArguments[0].Value!,
NeedsPatternPlaceholder: (bool)attribute.ConstructorArguments[1].Value!,
NullNodeBaseCtorParamCount: targetSymbol.InstanceConstructors.Min(m => m.Parameters.Length),
IsTypeNode: targetSymbol.Name == "AstType" || targetSymbol.BaseType?.Name == "AstType",
visitMethodName, paramTypeName, membersToMatch?.ToEquatableArray());
}
void WriteGeneratedMembers(SourceProductionContext context, AstNodeAdditions source)
{
var builder = new StringBuilder();
builder.AppendLine("namespace ICSharpCode.Decompiler.CSharp.Syntax;");
builder.AppendLine();
if (source.NeedsPatternPlaceholder)
{
builder.AppendLine("using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;");
}
builder.AppendLine();
builder.AppendLine("#nullable enable");
builder.AppendLine();
builder.AppendLine($"partial class {source.NodeName}");
builder.AppendLine("{");
if (source.NeedsNullNode)
{
bool needsNew = source.NodeName != "AstNode";
builder.AppendLine($" {(needsNew ? "new " : "")}public static readonly {source.NodeName} Null = new Null{source.NodeName}();");
builder.AppendLine($@"
sealed class Null{source.NodeName} : {source.NodeName}
{{
public override NodeType NodeType => NodeType.Unknown;
public override bool IsNull => true;
public override void AcceptVisitor(IAstVisitor visitor)
{{
visitor.VisitNullNode(this);
}}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{{
return visitor.VisitNullNode(this);
}}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{{
return visitor.VisitNullNode(this, data);
}}
protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{{
return other == null || other.IsNull;
}}");
if (source.IsTypeNode)
{
builder.AppendLine(
$@"
public override Decompiler.TypeSystem.ITypeReference ToTypeReference(Resolver.NameLookupMode lookupMode, Decompiler.TypeSystem.InterningProvider? interningProvider = null)
{{
return Decompiler.TypeSystem.SpecialType.UnknownType;
}}"
);
}
if (source.NullNodeBaseCtorParamCount > 0)
{
builder.AppendLine($@"
public Null{source.NodeName}() : base({string.Join(", ", Enumerable.Repeat("default", source.NullNodeBaseCtorParamCount))}) {{ }}");
}
builder.AppendLine($@"
}}
");
}
if (source.NeedsPatternPlaceholder)
{
const string toTypeReferenceCode = @"
public override Decompiler.TypeSystem.ITypeReference ToTypeReference(Resolver.NameLookupMode lookupMode, Decompiler.TypeSystem.InterningProvider? interningProvider = null)
{
throw new System.NotSupportedException();
}";
builder.Append(
$@" public static implicit operator {source.NodeName}?(PatternMatching.Pattern? pattern)
{{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}}
sealed class PatternPlaceholder : {source.NodeName}, INode
{{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{{
this.child = child;
}}
public override NodeType NodeType {{
get {{ return NodeType.Pattern; }}
}}
public override void AcceptVisitor(IAstVisitor visitor)
{{
visitor.VisitPatternPlaceholder(this, child);
}}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{{
return visitor.VisitPatternPlaceholder(this, child);
}}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{{
return visitor.VisitPatternPlaceholder(this, child, data);
}}
protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{{
return child.DoMatch(other, match);
}}
bool PatternMatching.INode.DoMatchCollection(Role? role, PatternMatching.INode? pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}}{(source.NodeName == "AstType" ? toTypeReferenceCode : "")}
}}
"
);
}
if (source.NeedsAcceptImpls && source.NeedsVisitor)
{
builder.Append($@" public override void AcceptVisitor(IAstVisitor visitor)
{{
visitor.Visit{source.VisitMethodName}(this);
}}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{{
return visitor.Visit{source.VisitMethodName}(this);
}}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{{
return visitor.Visit{source.VisitMethodName}(this, data);
}}
");
}
if (source.MembersToMatch != null)
{
builder.Append($@" protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{{
return other is {source.NodeName} o && !o.IsNull");
foreach (var (member, typeName, recursive, hasAny) in source.MembersToMatch)
{
if (member == "MatchAttributesAndModifiers")
{
builder.Append($"\r\n\t\t\t&& this.MatchAttributesAndModifiers(o, match)");
}
else if (recursive)
{
builder.Append($"\r\n\t\t\t&& this.{member}.DoMatch(o.{member}, match)");
}
else if (hasAny)
{
builder.Append($"\r\n\t\t\t&& (this.{member} == {typeName}.Any || this.{member} == o.{member})");
}
else if (typeName == "String")
{
builder.Append($"\r\n\t\t\t&& MatchString(this.{member}, o.{member})");
}
else
{
builder.Append($"\r\n\t\t\t&& this.{member} == o.{member}");
}
}
builder.Append(@";
}
");
}
builder.AppendLine("}");
context.AddSource(source.NodeName + ".g.cs", SourceText.From(builder.ToString(), Encoding.UTF8));
}
void WriteVisitors(SourceProductionContext context, ImmutableArray<AstNodeAdditions> source)
{
var builder = new StringBuilder();
builder.AppendLine("namespace ICSharpCode.Decompiler.CSharp.Syntax;");
source = source
.Concat([new("NullNode", false, true, false, false, 0, false, "NullNode", "AstNode", null), new("PatternPlaceholder", false, true, false, false, 0, false, "PatternPlaceholder", "AstNode", null)])
.ToImmutableArray();
WriteInterface("IAstVisitor", "void", "");
WriteInterface("IAstVisitor<out S>", "S", "");
WriteInterface("IAstVisitor<in T, out S>", "S", ", T data");
context.AddSource("IAstVisitor.g.cs", SourceText.From(builder.ToString(), Encoding.UTF8));
void WriteInterface(string name, string ret, string param)
{
builder.AppendLine($"public interface {name}");
builder.AppendLine("{");
foreach (var type in source.OrderBy(t => t.VisitMethodName))
{
if (!type.NeedsVisitor)
continue;
string extParams, paramName;
if (type.VisitMethodName == "PatternPlaceholder")
{
paramName = "placeholder";
extParams = ", PatternMatching.Pattern pattern" + param;
}
else
{
paramName = char.ToLowerInvariant(type.VisitMethodName[0]) + type.VisitMethodName.Substring(1);
extParams = param;
}
builder.AppendLine($"\t{ret} Visit{type.VisitMethodName}({type.VisitMethodParamType} {paramName}{extParams});");
}
builder.AppendLine("}");
}
}
public void Initialize(IncrementalGeneratorInitializationContext context)
{
var astNodeAdditions = context.SyntaxProvider.ForAttributeWithMetadataName(
"ICSharpCode.Decompiler.CSharp.Syntax.DecompilerAstNodeAttribute",
(n, ct) => n is ClassDeclarationSyntax,
GetAstNodeAdditions);
var visitorMembers = astNodeAdditions.Collect();
context
.RegisterPostInitializationOutput(i => i.AddSource("DecompilerSyntaxTreeGeneratorAttributes.g.cs", @"
using System;
namespace Microsoft.CodeAnalysis
{
internal sealed partial class EmbeddedAttribute : global::System.Attribute
{
}
}
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
sealed class DecompilerAstNodeAttribute : global::System.Attribute
{
public DecompilerAstNodeAttribute(bool hasNullNode = false, bool hasPatternPlaceholder = false) { }
}
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
sealed class ExcludeFromMatchAttribute : global::System.Attribute
{
}
}
"));
context.RegisterSourceOutput(astNodeAdditions, WriteGeneratedMembers);
context.RegisterSourceOutput(visitorMembers, WriteVisitors);
}
}
readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnumerable<T>
where T : IEquatable<T>
{
readonly T[] array;
public EquatableArray(T[] array)
{
this.array = array ?? throw new ArgumentNullException(nameof(array));
}
public bool Equals(EquatableArray<T> other)
{
return other.array.AsSpan().SequenceEqual(this.array);
}
public IEnumerator<T> GetEnumerator()
{
return ((IEnumerable<T>)array).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return array.GetEnumerator();
}
}
static class EquatableArrayExtensions
{
public static EquatableArray<T> ToEquatableArray<T>(this List<T> array) where T : IEquatable<T>
{
return new EquatableArray<T>(array.ToArray());
}
}

16
ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>
</Project>

3
ICSharpCode.Decompiler.Generators/IsExternalInit.cs

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
namespace System.Runtime.CompilerServices;
class IsExternalInit { }

32
ICSharpCode.Decompiler.Generators/RoslynHelpers.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
using Microsoft.CodeAnalysis;
namespace ICSharpCode.Decompiler.Generators;
public static class RoslynHelpers
{
public static IEnumerable<INamedTypeSymbol> GetTopLevelTypes(this IAssemblySymbol assembly)
{
foreach (var ns in TreeTraversal.PreOrder(assembly.GlobalNamespace, ns => ns.GetNamespaceMembers()))
{
foreach (var t in ns.GetTypeMembers())
{
yield return t;
}
}
}
public static bool IsDerivedFrom(this INamedTypeSymbol type, INamedTypeSymbol baseType)
{
INamedTypeSymbol? t = type;
while (t != null)
{
if (SymbolEqualityComparer.Default.Equals(t, baseType))
return true;
t = t.BaseType;
}
return false;
}
}

125
ICSharpCode.Decompiler.Generators/TreeTraversal.cs

@ -0,0 +1,125 @@ @@ -0,0 +1,125 @@
#nullable enable
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace ICSharpCode.Decompiler.Generators;
/// <summary>
/// Static helper methods for traversing trees.
/// </summary>
internal static class TreeTraversal
{
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in pre-order.
/// </summary>
/// <param name="root">The root element of the tree.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in pre-order.</returns>
public static IEnumerable<T> PreOrder<T>(T root, Func<T, IEnumerable<T>?> recursion)
{
return PreOrder(new T[] { root }, recursion);
}
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in pre-order.
/// </summary>
/// <param name="input">The root elements of the forest.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in pre-order.</returns>
public static IEnumerable<T> PreOrder<T>(IEnumerable<T> input, Func<T, IEnumerable<T>?> recursion)
{
Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>();
try
{
stack.Push(input.GetEnumerator());
while (stack.Count > 0)
{
while (stack.Peek().MoveNext())
{
T element = stack.Peek().Current;
yield return element;
IEnumerable<T>? children = recursion(element);
if (children != null)
{
stack.Push(children.GetEnumerator());
}
}
stack.Pop().Dispose();
}
}
finally
{
while (stack.Count > 0)
{
stack.Pop().Dispose();
}
}
}
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in post-order.
/// </summary>
/// <param name="root">The root element of the tree.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in post-order.</returns>
public static IEnumerable<T> PostOrder<T>(T root, Func<T, IEnumerable<T>?> recursion)
{
return PostOrder(new T[] { root }, recursion);
}
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in post-order.
/// </summary>
/// <param name="input">The root elements of the forest.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in post-order.</returns>
public static IEnumerable<T> PostOrder<T>(IEnumerable<T> input, Func<T, IEnumerable<T>?> recursion)
{
Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>();
try
{
stack.Push(input.GetEnumerator());
while (stack.Count > 0)
{
while (stack.Peek().MoveNext())
{
T element = stack.Peek().Current;
IEnumerable<T>? children = recursion(element);
if (children != null)
{
stack.Push(children.GetEnumerator());
}
else
{
yield return element;
}
}
stack.Pop().Dispose();
if (stack.Count > 0)
yield return stack.Peek().Current;
}
}
finally
{
while (stack.Count > 0)
{
stack.Pop().Dispose();
}
}
}
}

88
ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs

@ -37,96 +37,12 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -37,96 +37,12 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public abstract class AstNode : AbstractAnnotatable, IFreezable, INode, ICloneable
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class AstNode : AbstractAnnotatable, IFreezable, INode, ICloneable
{
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class
internal static readonly Role<AstNode?> RootRole = new Role<AstNode?>("Root", null);
#region Null
public static readonly AstNode Null = new NullAstNode();
sealed class NullAstNode : AstNode
{
public override NodeType NodeType {
get {
return NodeType.Unknown;
}
}
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
#region PatternPlaceholder
public static implicit operator AstNode?(PatternMatching.Pattern? pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : AstNode, INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role? role, PatternMatching.INode? pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
AstNode? parent;
AstNode? prevSibling;
AstNode? nextSibling;

94
ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs

@ -16,11 +16,9 @@ @@ -16,11 +16,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax
@ -28,97 +26,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -28,97 +26,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// A type reference in the C# AST.
/// </summary>
public abstract class AstType : AstNode
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class AstType : AstNode
{
#region Null
public new static readonly AstType Null = new NullAstType();
sealed class NullAstType : AstType
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider)
{
return SpecialType.UnknownType;
}
}
#endregion
#region PatternPlaceholder
public static implicit operator AstType(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : AstType, INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider)
{
throw new NotSupportedException();
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get { return NodeType.TypeReference; }
}

3
ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs

@ -31,7 +31,8 @@ using ICSharpCode.Decompiler.CSharp.OutputVisitor; @@ -31,7 +31,8 @@ using ICSharpCode.Decompiler.CSharp.OutputVisitor;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class CSharpModifierToken : CSharpTokenNode
[DecompilerAstNode(hasNullNode: false)]
public partial class CSharpModifierToken : CSharpTokenNode
{
Modifiers modifier;

52
ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs

@ -34,42 +34,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -34,42 +34,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <remarks>
/// In all non null c# token nodes the Role of a CSharpToken must be a TokenRole.
/// </remarks>
public class CSharpTokenNode : AstNode
[DecompilerAstNode(hasNullNode: true)]
public partial class CSharpTokenNode : AstNode
{
public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode();
class NullCSharpTokenNode : CSharpTokenNode
{
public override bool IsNull {
get {
return true;
}
}
public NullCSharpTokenNode() : base(TextLocation.Empty, null)
{
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
public override NodeType NodeType {
get {
return NodeType.Token;
@ -117,21 +84,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -117,21 +84,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return string.Empty;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitCSharpTokenNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitCSharpTokenNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCSharpTokenNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CSharpTokenNode o = other as CSharpTokenNode;

36
ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs

@ -34,7 +34,8 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -34,7 +34,8 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class ComposedType : AstType
[DecompilerAstNode(hasNullNode: false)]
public partial class ComposedType : AstType
{
public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole;
public static readonly TokenRole RefRole = new TokenRole("ref");
@ -129,21 +130,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -129,21 +130,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildrenByRole(PointerRole); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitComposedType(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitComposedType(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitComposedType(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ComposedType o = other as ComposedType;
@ -230,7 +216,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -230,7 +216,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// [,,,]
/// </summary>
public class ArraySpecifier : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class ArraySpecifier : AstNode
{
public override NodeType NodeType {
get {
@ -272,21 +259,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -272,21 +259,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RBracket); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitArraySpecifier(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitArraySpecifier(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitArraySpecifier(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ArraySpecifier o = other as ArraySpecifier;

18
ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs

@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Represents a 'cref' reference in XML documentation.
/// </summary>
public class DocumentationReference : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class DocumentationReference : AstNode
{
public static readonly Role<AstType> DeclaringTypeRole = new Role<AstType>("DeclaringType", AstType.Null);
public static readonly Role<AstType> ConversionOperatorReturnTypeRole = new Role<AstType>("ConversionOperatorReturnType", AstType.Null);
@ -133,20 +134,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -133,20 +134,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
return this.Parameters.DoMatch(o.Parameters, match);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitDocumentationReference(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitDocumentationReference(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDocumentationReference(this, data);
}
}
}

25
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// [async] delegate(Parameters) {Body}
/// </summary>
public class AnonymousMethodExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class AnonymousMethodExpression : Expression
{
public readonly static TokenRole DelegateKeywordRole = new TokenRole("delegate");
public readonly static TokenRole AsyncModifierRole = LambdaExpression.AsyncModifierRole;
@ -93,27 +94,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -93,27 +94,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AnonymousMethodExpression(BlockStatement body, params ParameterDeclaration[] parameters) : this(body, (IEnumerable<ParameterDeclaration>)parameters)
{
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitAnonymousMethodExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitAnonymousMethodExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAnonymousMethodExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
AnonymousMethodExpression o = other as AnonymousMethodExpression;
return o != null && this.IsAsync == o.IsAsync && this.HasParameterList == o.HasParameterList
&& this.Parameters.DoMatch(o.Parameters, match) && this.Body.DoMatch(o.Body, match);
}
}
}

24
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// new { [ExpressionList] }
/// </summary>
public class AnonymousTypeCreateExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class AnonymousTypeCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole("new");
@ -65,27 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -65,27 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AnonymousTypeCreateExpression(params Expression[] initializer) : this((IEnumerable<Expression>)initializer)
{
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitAnonymousTypeCreateExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitAnonymousTypeCreateExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAnonymousTypeCreateExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as AnonymousTypeCreateExpression;
return o != null && this.Initializers.DoMatch(o.Initializers, match);
}
}
}

28
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs

@ -16,13 +16,13 @@ @@ -16,13 +16,13 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// new Type[Dimensions]
/// </summary>
public class ArrayCreateExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class ArrayCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole("new");
public readonly static Role<ArraySpecifier> AdditionalArraySpecifierRole = new Role<ArraySpecifier>("AdditionalArraySpecifier", null);
@ -53,29 +53,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -53,29 +53,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(InitializerRole); }
set { SetChildByRole(InitializerRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitArrayCreateExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitArrayCreateExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitArrayCreateExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ArrayCreateExpression o = other as ArrayCreateExpression;
return o != null && this.Type.DoMatch(o.Type, match)
&& this.Arguments.DoMatch(o.Arguments, match)
&& this.AdditionalArraySpecifiers.DoMatch(o.AdditionalArraySpecifiers, match)
&& this.Initializer.DoMatch(o.Initializer, match);
}
}
}

132
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs

@ -31,20 +31,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,20 +31,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// { Elements }
/// </summary>
public class ArrayInitializerExpression : Expression
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public partial class ArrayInitializerExpression : Expression
{
/// <summary>
/// For ease of use purposes in the resolver the ast representation
/// of { a, b, c } is { {a}, {b}, {c} }.
/// If IsSingleElement is true then this array initializer expression is a generated one.
/// That has no meaning in the source code (and contains no brace tokens).
/// </summary>
public virtual bool IsSingleElement {
get {
return false;
}
}
public ArrayInitializerExpression()
{
}
@ -59,39 +48,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -59,39 +48,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.Elements.AddRange(elements);
}
#region Null
public new static readonly ArrayInitializerExpression Null = new NullArrayInitializerExpression();
sealed class NullArrayInitializerExpression : ArrayInitializerExpression
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
public CSharpTokenNode LBraceToken {
get { return GetChildByRole(Roles.LBrace); }
}
@ -103,90 +59,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -103,90 +59,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public CSharpTokenNode RBraceToken {
get { return GetChildByRole(Roles.RBrace); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitArrayInitializerExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitArrayInitializerExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitArrayInitializerExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ArrayInitializerExpression o = other as ArrayInitializerExpression;
return o != null && this.Elements.DoMatch(o.Elements, match);
}
public static ArrayInitializerExpression CreateSingleElementInitializer()
{
return new SingleArrayInitializerExpression();
}
/// <summary>
/// Single elements in array initializers are represented with this special class.
/// </summary>
class SingleArrayInitializerExpression : ArrayInitializerExpression
{
public override bool IsSingleElement {
get {
return true;
}
}
}
#region PatternPlaceholder
public static implicit operator ArrayInitializerExpression(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : ArrayInitializerExpression, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
}
}

26
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs

@ -23,14 +23,13 @@ @@ -23,14 +23,13 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// Expression as TypeReference
/// </summary>
public class AsExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class AsExpression : Expression
{
public readonly static TokenRole AsKeywordRole = new TokenRole("as");
@ -57,27 +56,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -57,27 +56,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(expression, Roles.Expression);
AddChild(type, Roles.Type);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitAsExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitAsExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAsExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
AsExpression o = other as AsExpression;
return o != null && this.Expression.DoMatch(o.Expression, match) && this.Type.DoMatch(o.Type, match);
}
}
}

26
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs

@ -25,7 +25,6 @@ @@ -25,7 +25,6 @@
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace ICSharpCode.Decompiler.CSharp.Syntax
@ -33,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -33,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Left Operator= Right
/// </summary>
public class AssignmentExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class AssignmentExpression : Expression
{
// reuse roles from BinaryOperatorExpression
public readonly static Role<Expression> LeftRole = BinaryOperatorExpression.LeftRole;
@ -88,28 +88,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -88,28 +88,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(RightRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitAssignmentExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitAssignmentExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAssignmentExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
AssignmentExpression o = other as AssignmentExpression;
return o != null && (this.Operator == AssignmentOperatorType.Any || this.Operator == o.Operator)
&& this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match);
}
public static TokenRole GetOperatorRole(AssignmentOperatorType op)
{
switch (op)

25
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs

@ -24,13 +24,13 @@ @@ -24,13 +24,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// base
/// </summary>
public class BaseReferenceExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class BaseReferenceExpression : Expression
{
public TextLocation Location {
get;
@ -47,26 +47,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -47,26 +47,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return new TextLocation(Location.Line, Location.Column + "base".Length);
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitBaseReferenceExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitBaseReferenceExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBaseReferenceExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
BaseReferenceExpression o = other as BaseReferenceExpression;
return o != null;
}
}
}

25
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Left Operator Right
/// </summary>
public class BinaryOperatorExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class BinaryOperatorExpression : Expression
{
public readonly static TokenRole BitwiseAndRole = new TokenRole("&");
public readonly static TokenRole BitwiseOrRole = new TokenRole("|");
@ -90,28 +91,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -90,28 +91,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(RightRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitBinaryOperatorExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitBinaryOperatorExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBinaryOperatorExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
BinaryOperatorExpression o = other as BinaryOperatorExpression;
return o != null && (this.Operator == BinaryOperatorType.Any || this.Operator == o.Operator)
&& this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match);
}
public static TokenRole GetOperatorRole(BinaryOperatorType op)
{
switch (op)

26
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs

@ -23,14 +23,13 @@ @@ -23,14 +23,13 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// (CastTo)Expression
/// </summary>
public class CastExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class CastExpression : Expression
{
public CSharpTokenNode LParToken {
get { return GetChildByRole(Roles.LPar); }
@ -59,27 +58,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -59,27 +58,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(castToType, Roles.Type);
AddChild(expression, Roles.Expression);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitCastExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitCastExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCastExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CastExpression o = other as CastExpression;
return o != null && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match);
}
}
}

25
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs

@ -24,13 +24,13 @@ @@ -24,13 +24,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// checked(Expression)
/// </summary>
public class CheckedExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class CheckedExpression : Expression
{
public readonly static TokenRole CheckedKeywordRole = new TokenRole("checked");
@ -59,26 +59,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -59,26 +59,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
AddChild(expression, Roles.Expression);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitCheckedExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitCheckedExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCheckedExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CheckedExpression o = other as CheckedExpression;
return o != null && this.Expression.DoMatch(o.Expression, match);
}
}
}

26
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs

@ -23,14 +23,13 @@ @@ -23,14 +23,13 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// Condition ? TrueExpression : FalseExpression
/// </summary>
public class ConditionalExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class ConditionalExpression : Expression
{
public readonly static Role<Expression> ConditionRole = Roles.Condition;
public readonly static TokenRole QuestionMarkRole = new TokenRole("?");
@ -71,26 +70,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -71,26 +70,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(trueExpression, TrueRole);
AddChild(falseExpression, FalseRole);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitConditionalExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitConditionalExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitConditionalExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ConditionalExpression o = other as ConditionalExpression;
return o != null && this.Condition.DoMatch(o.Condition, match) && this.TrueExpression.DoMatch(o.TrueExpression, match) && this.FalseExpression.DoMatch(o.FalseExpression, match);
}
}
}

27
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs

@ -16,14 +16,13 @@ @@ -16,14 +16,13 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// TypeName VariableDesignation
/// </summary>
public class DeclarationExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class DeclarationExpression : Expression
{
public AstType Type {
get { return GetChildByRole(Roles.Type); }
@ -34,27 +33,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -34,27 +33,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.VariableDesignationRole); }
set { SetChildByRole(Roles.VariableDesignationRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitDeclarationExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitDeclarationExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDeclarationExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return other is DeclarationExpression o
&& Type.DoMatch(o.Type, match)
&& Designation.DoMatch(o.Designation, match);
}
}
}

30
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DecompilerAstNodeAttribute.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
// Copyright (c) 2017 Siegfried Pammer
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
class DecompilerAstNodeAttribute : System.Attribute
{
}
}

24
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// default(Type)
/// </summary>
public class DefaultValueExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class DefaultValueExpression : Expression
{
public readonly static TokenRole DefaultKeywordRole = new TokenRole("default");
@ -59,27 +60,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -59,27 +60,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
AddChild(type, Roles.Type);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitDefaultValueExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitDefaultValueExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDefaultValueExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DefaultValueExpression o = other as DefaultValueExpression;
return o != null && this.Type.DoMatch(o.Type, match);
}
}
}

24
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs

@ -38,7 +38,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -38,7 +38,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// ref Expression
/// </summary>
public class DirectionExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class DirectionExpression : Expression
{
public readonly static TokenRole RefKeywordRole = new TokenRole("ref");
public readonly static TokenRole OutKeywordRole = new TokenRole("out");
@ -77,26 +78,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -77,26 +78,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.FieldDirection = direction;
AddChild(expression, Roles.Expression);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitDirectionExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitDirectionExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDirectionExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DirectionExpression o = other as DirectionExpression;
return o != null && this.FieldDirection == o.FieldDirection && this.Expression.DoMatch(o.Expression, match);
}
}
}

31
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs

@ -23,11 +23,10 @@ @@ -23,11 +23,10 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class ErrorExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class ErrorExpression : Expression
{
public TextLocation Location { get; set; }
@ -43,11 +42,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -43,11 +42,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public string Error {
get;
private set;
}
public ErrorExpression()
{
}
@ -56,27 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -56,27 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
AddChild(new Comment(error, CommentType.MultiLine), Roles.Comment);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitErrorNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitErrorNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitErrorNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as ErrorExpression;
return o != null;
}
}
}

83
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
@ -28,87 +27,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -28,87 +27,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// This class is useful even though it doesn't provide any additional functionality:
/// It can be used to communicate more information in APIs, e.g. "this subnode will always be an expression"
/// </remarks>
public abstract class Expression : AstNode
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class Expression : AstNode
{
#region Null
public new static readonly Expression Null = new NullExpression();
sealed class NullExpression : Expression
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
#region PatternPlaceholder
public static implicit operator Expression(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : Expression, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get {
return NodeType.Expression;

24
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs

@ -26,7 +26,8 @@ @@ -26,7 +26,8 @@
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class IdentifierExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class IdentifierExpression : Expression
{
public IdentifierExpression()
{
@ -63,26 +64,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -63,26 +64,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole(Roles.TypeArgument); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitIdentifierExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitIdentifierExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIdentifierExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
IdentifierExpression o = other as IdentifierExpression;
return o != null && MatchString(this.Identifier, o.Identifier) && this.TypeArguments.DoMatch(o.TypeArguments, match);
}
}
}

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Target[Arguments]
/// </summary>
public class IndexerExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class IndexerExpression : Expression
{
public Expression Target {
get { return GetChildByRole(Roles.TargetExpression); }
@ -70,21 +71,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -70,21 +71,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitIndexerExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitIndexerExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIndexerExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
IndexerExpression o = other as IndexerExpression;

94
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs

@ -1,12 +1,11 @@ @@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class InterpolatedStringExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class InterpolatedStringExpression : Expression
{
public static readonly TokenRole OpenQuote = new TokenRole("$\"");
public static readonly TokenRole CloseQuote = new TokenRole("\"");
@ -25,21 +24,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -25,21 +24,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Content.AddRange(content);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitInterpolatedStringExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitInterpolatedStringExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitInterpolatedStringExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
InterpolatedStringExpression o = other as InterpolatedStringExpression;
@ -47,41 +31,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -47,41 +31,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public abstract class InterpolatedStringContent : AstNode
[DecompilerAstNode(hasNullNode: true)]
public abstract partial class InterpolatedStringContent : AstNode
{
#region Null
public new static readonly InterpolatedStringContent Null = new NullInterpolatedStringContent();
sealed class NullInterpolatedStringContent : InterpolatedStringContent
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
public new static readonly Role<InterpolatedStringContent> Role = new Role<InterpolatedStringContent>("InterpolatedStringContent", Syntax.InterpolatedStringContent.Null);
public override NodeType NodeType => NodeType.Unknown;
@ -90,7 +42,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -90,7 +42,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// { Expression , Alignment : Suffix }
/// </summary>
public class Interpolation : InterpolatedStringContent
[DecompilerAstNode(hasNullNode: false)]
public partial class Interpolation : InterpolatedStringContent
{
public static readonly TokenRole LBrace = new TokenRole("{");
public static readonly TokenRole RBrace = new TokenRole("}");
@ -124,21 +77,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -124,21 +77,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Suffix = suffix;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitInterpolation(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitInterpolation(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitInterpolation(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
Interpolation o = other as Interpolation;
@ -146,7 +84,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -146,7 +84,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class InterpolatedStringText : InterpolatedStringContent
[DecompilerAstNode(hasNullNode: false)]
public partial class InterpolatedStringText : InterpolatedStringContent
{
public string Text { get; set; }
@ -160,21 +99,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -160,21 +99,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Text = text;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitInterpolatedStringText(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitInterpolatedStringText(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitInterpolatedStringText(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
InterpolatedStringText o = other as InterpolatedStringText;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Target(Arguments)
/// </summary>
public class InvocationExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class InvocationExpression : Expression
{
public Expression Target {
get { return GetChildByRole(Roles.TargetExpression); }
@ -50,21 +51,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -50,21 +51,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RPar); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitInvocationExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitInvocationExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitInvocationExpression(this, data);
}
public InvocationExpression()
{
}

21
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs

@ -23,14 +23,13 @@ @@ -23,14 +23,13 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// Expression is Type
/// </summary>
public class IsExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class IsExpression : Expression
{
public readonly static TokenRole IsKeywordRole = new TokenRole("is");
@ -58,22 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -58,22 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(type, Roles.Type);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitIsExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitIsExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIsExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
IsExpression o = other as IsExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// [async] Parameters => Body
/// </summary>
public class LambdaExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class LambdaExpression : Expression
{
public static readonly Role<AttributeSection> AttributeRole = new Role<AttributeSection>("Attribute", null);
public readonly static TokenRole AsyncModifierRole = new TokenRole("async");
@ -67,21 +68,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -67,21 +68,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(BodyRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitLambdaExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitLambdaExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitLambdaExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
LambdaExpression o = other as LambdaExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Target.MemberName
/// </summary>
public class MemberReferenceExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class MemberReferenceExpression : Expression
{
public Expression Target {
get {
@ -97,21 +98,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -97,21 +98,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitMemberReferenceExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitMemberReferenceExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitMemberReferenceExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
MemberReferenceExpression o = other as MemberReferenceExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs

@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Represents a named argument passed to a method or attribute.
/// name: expression
/// </summary>
public class NamedArgumentExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class NamedArgumentExpression : Expression
{
public NamedArgumentExpression()
{
@ -62,21 +63,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -62,21 +63,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Expression, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNamedArgumentExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNamedArgumentExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNamedArgumentExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
NamedArgumentExpression o = other as NamedArgumentExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// This isn't the same as 'assign' even though it has the same syntax.
/// This expression is used in object initializers and for named attribute arguments [Attr(FieldName = value)].
/// </summary>
public class NamedExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class NamedExpression : Expression
{
public NamedExpression()
{
@ -71,21 +72,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -71,21 +72,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Expression, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNamedExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNamedExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNamedExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as NamedExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// null
/// </summary>
public class NullReferenceExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class NullReferenceExpression : Expression
{
TextLocation location;
public override TextLocation StartLocation {
@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.location = location;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullReferenceExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullReferenceExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullReferenceExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
NullReferenceExpression o = other as NullReferenceExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// new Type(Arguments) { Initializer }
/// </summary>
public class ObjectCreateExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class ObjectCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole("new");
public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole;
@ -82,21 +83,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -82,21 +83,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitObjectCreateExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitObjectCreateExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitObjectCreateExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ObjectCreateExpression o = other as ObjectCreateExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs

@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// out type expression
/// </summary>
public class OutVarDeclarationExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class OutVarDeclarationExpression : Expression
{
public readonly static TokenRole OutKeywordRole = DirectionExpression.OutKeywordRole;
@ -49,21 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -49,21 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.Variable = new VariableInitializer(name);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitOutVarDeclarationExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitOutVarDeclarationExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitOutVarDeclarationExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as OutVarDeclarationExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// ( Expression )
/// </summary>
public class ParenthesizedExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class ParenthesizedExpression : Expression
{
public CSharpTokenNode LParToken {
get { return GetChildByRole(Roles.LPar); }
@ -54,21 +55,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -54,21 +55,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Expression = expr;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitParenthesizedExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitParenthesizedExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitParenthesizedExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ParenthesizedExpression o = other as ParenthesizedExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Target->MemberName
/// </summary>
public class PointerReferenceExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class PointerReferenceExpression : Expression
{
public readonly static TokenRole ArrowRole = new TokenRole("->");
@ -65,21 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -65,21 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildrenByRole(Roles.TypeArgument); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPointerReferenceExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPointerReferenceExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPointerReferenceExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
PointerReferenceExpression o = other as PointerReferenceExpression;

20
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs

@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.CSharp.Syntax
@ -48,7 +46,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -48,7 +46,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Represents a literal value.
/// </summary>
public class PrimitiveExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class PrimitiveExpression : Expression
{
public static readonly object AnyValue = new object();
@ -95,21 +94,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -95,21 +94,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.format = format;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPrimitiveExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPrimitiveExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPrimitiveExpression(this, data);
}
unsafe static TextLocation AdvanceLocation(TextLocation startLocation, string str)
{
int line = startLocation.Line;

213
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs

@ -18,62 +18,15 @@ @@ -18,62 +18,15 @@
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class QueryExpression : Expression
[DecompilerAstNode(hasNullNode: true)]
public partial class QueryExpression : Expression
{
public static readonly Role<QueryClause> ClauseRole = new Role<QueryClause>("Clause", null);
#region Null
public new static readonly QueryExpression Null = new NullQueryExpression();
sealed class NullQueryExpression : QueryExpression
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
public AstNodeCollection<QueryClause> Clauses {
get { return GetChildrenByRole(ClauseRole); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryExpression o = other as QueryExpression;
@ -106,7 +59,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -106,7 +59,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// new QuerySelectClause(e)
/// }
/// </summary>
public class QueryContinuationClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryContinuationClause : QueryClause
{
public static readonly Role<QueryExpression> PrecedingQueryRole = new Role<QueryExpression>("PrecedingQuery", QueryExpression.Null);
public static readonly TokenRole IntoKeywordRole = new TokenRole("into");
@ -133,21 +87,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -133,21 +87,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Identifier); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryContinuationClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryContinuationClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryContinuationClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryContinuationClause o = other as QueryContinuationClause;
@ -155,7 +94,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -155,7 +94,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class QueryFromClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryFromClause : QueryClause
{
public static readonly TokenRole FromKeywordRole = new TokenRole("from");
public static readonly TokenRole InKeywordRole = new TokenRole("in");
@ -191,21 +131,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -191,21 +131,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Expression, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryFromClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryFromClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryFromClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryFromClause o = other as QueryFromClause;
@ -214,7 +139,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -214,7 +139,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class QueryLetClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryLetClause : QueryClause
{
public readonly static TokenRole LetKeywordRole = new TokenRole("let");
@ -244,21 +170,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -244,21 +170,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Expression, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryLetClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryLetClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryLetClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryLetClause o = other as QueryLetClause;
@ -267,7 +178,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -267,7 +178,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
public class QueryWhereClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryWhereClause : QueryClause
{
public readonly static TokenRole WhereKeywordRole = new TokenRole("where");
@ -280,21 +192,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -280,21 +192,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Condition, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryWhereClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryWhereClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryWhereClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryWhereClause o = other as QueryWhereClause;
@ -305,7 +202,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -305,7 +202,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Represents a join or group join clause.
/// </summary>
public class QueryJoinClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryJoinClause : QueryClause
{
public static readonly TokenRole JoinKeywordRole = new TokenRole("join");
public static readonly Role<AstType> TypeRole = Roles.Type;
@ -389,21 +287,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -389,21 +287,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(IntoIdentifierRole); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryJoinClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryJoinClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryJoinClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryJoinClause o = other as QueryJoinClause;
@ -415,7 +298,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -415,7 +298,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class QueryOrderClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryOrderClause : QueryClause
{
public static readonly TokenRole OrderbyKeywordRole = new TokenRole("orderby");
public static readonly Role<QueryOrdering> OrderingRole = new Role<QueryOrdering>("Ordering", null);
@ -428,21 +312,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -428,21 +312,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildrenByRole(OrderingRole); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryOrderClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryOrderClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryOrderClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryOrderClause o = other as QueryOrderClause;
@ -450,7 +319,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -450,7 +319,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class QueryOrdering : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryOrdering : AstNode
{
public readonly static TokenRole AscendingKeywordRole = new TokenRole("ascending");
public readonly static TokenRole DescendingKeywordRole = new TokenRole("descending");
@ -473,21 +343,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -473,21 +343,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return Direction == QueryOrderingDirection.Ascending ? GetChildByRole(AscendingKeywordRole) : GetChildByRole(DescendingKeywordRole); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryOrdering(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryOrdering(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryOrdering(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryOrdering o = other as QueryOrdering;
@ -502,7 +357,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -502,7 +357,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Descending
}
public class QuerySelectClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QuerySelectClause : QueryClause
{
public readonly static TokenRole SelectKeywordRole = new TokenRole("select");
@ -515,21 +371,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -515,21 +371,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Expression, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQuerySelectClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQuerySelectClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQuerySelectClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QuerySelectClause o = other as QuerySelectClause;
@ -537,7 +378,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -537,7 +378,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class QueryGroupClause : QueryClause
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryGroupClause : QueryClause
{
public static readonly TokenRole GroupKeywordRole = new TokenRole("group");
public static readonly Role<Expression> ProjectionRole = new Role<Expression>("Projection", Expression.Null);
@ -562,21 +404,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -562,21 +404,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(KeyRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitQueryGroupClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitQueryGroupClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryGroupClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryGroupClause o = other as QueryGroupClause;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/RecursivePatternExpression.cs

@ -20,7 +20,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching; @@ -20,7 +20,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class RecursivePatternExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class RecursivePatternExpression : Expression
{
public static readonly Role<Expression> SubPatternRole = new Role<Expression>("SubPattern", Syntax.Expression.Null);
@ -40,21 +41,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -40,21 +41,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public bool IsPositional { get; set; }
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitRecursivePatternExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitRecursivePatternExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitRecursivePatternExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return other is RecursivePatternExpression o

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SizeOfExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// sizeof(Type)
/// </summary>
public class SizeOfExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class SizeOfExpression : Expression
{
public readonly static TokenRole SizeofKeywordRole = new TokenRole("sizeof");
@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(type, Roles.Type);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitSizeOfExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitSizeOfExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSizeOfExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SizeOfExpression o = other as SizeOfExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/StackAllocExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// stackalloc Type[Count]
/// </summary>
public class StackAllocExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class StackAllocExpression : Expression
{
public readonly static TokenRole StackallocKeywordRole = new TokenRole("stackalloc");
public readonly static Role<ArrayInitializerExpression> InitializerRole = new Role<ArrayInitializerExpression>("Initializer", ArrayInitializerExpression.Null);
@ -62,21 +63,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -62,21 +63,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(InitializerRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitStackAllocExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitStackAllocExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitStackAllocExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
StackAllocExpression o = other as StackAllocExpression;

36
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SwitchExpression.cs

@ -22,7 +22,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -22,7 +22,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Expression switch { SwitchSections }
/// </summary>
public class SwitchExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class SwitchExpression : Expression
{
public static readonly TokenRole SwitchKeywordRole = new TokenRole("switch");
public static readonly Role<SwitchExpressionSection> SwitchSectionRole = new Role<SwitchExpressionSection>("SwitchSection", null);
@ -48,21 +49,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -48,21 +49,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RBrace); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitSwitchExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitSwitchExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSwitchExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SwitchExpression o = other as SwitchExpression;
@ -73,7 +59,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -73,7 +59,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Pattern => Expression
/// </summary>
public class SwitchExpressionSection : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class SwitchExpressionSection : AstNode
{
public static readonly Role<Expression> PatternRole = new Role<Expression>("Pattern", Expression.Null);
public static readonly Role<Expression> BodyRole = new Role<Expression>("Body", Expression.Null);
@ -94,21 +81,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -94,21 +81,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public override NodeType NodeType => NodeType.Unknown;
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitSwitchExpressionSection(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitSwitchExpressionSection(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSwitchExpressionSection(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SwitchExpressionSection o = other as SwitchExpressionSection;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThisReferenceExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// this
/// </summary>
public class ThisReferenceExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class ThisReferenceExpression : Expression
{
public TextLocation Location {
get;
@ -48,21 +49,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -48,21 +49,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitThisReferenceExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitThisReferenceExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitThisReferenceExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ThisReferenceExpression o = other as ThisReferenceExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThrowExpression.cs

@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// throw Expression
/// </summary>
public class ThrowExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class ThrowExpression : Expression
{
public static readonly TokenRole ThrowKeywordRole = ThrowStatement.ThrowKeywordRole;
@ -43,21 +44,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -43,21 +44,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(expression, Roles.Expression);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitThrowExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitThrowExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitThrowExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ThrowExpression o = other as ThrowExpression;

20
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TupleExpression.cs

@ -16,33 +16,17 @@ @@ -16,33 +16,17 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class TupleExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class TupleExpression : Expression
{
public AstNodeCollection<Expression> Elements {
get { return GetChildrenByRole(Roles.Expression); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitTupleExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitTupleExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTupleExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return other is TupleExpression tuple

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeOfExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// typeof(Type)
/// </summary>
public class TypeOfExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class TypeOfExpression : Expression
{
public readonly static TokenRole TypeofKeywordRole = new TokenRole("typeof");
@ -61,21 +62,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -61,21 +62,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(type, Roles.Type);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitTypeOfExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitTypeOfExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeOfExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
TypeOfExpression o = other as TypeOfExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeReferenceExpression.cs

@ -23,28 +23,14 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -23,28 +23,14 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Represents an AstType as an expression.
/// This is used when calling a method on a primitive type: "int.Parse()"
/// </summary>
public class TypeReferenceExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class TypeReferenceExpression : Expression
{
public AstType Type {
get { return GetChildByRole(Roles.Type); }
set { SetChildByRole(Roles.Type, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitTypeReferenceExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitTypeReferenceExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeReferenceExpression(this, data);
}
public TypeReferenceExpression()
{
}

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Operator Expression
/// </summary>
public class UnaryOperatorExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class UnaryOperatorExpression : Expression
{
public readonly static TokenRole NotRole = new TokenRole("!");
public readonly static TokenRole BitNotRole = new TokenRole("~");
@ -72,21 +73,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -72,21 +73,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Expression, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitUnaryOperatorExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitUnaryOperatorExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUnaryOperatorExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
UnaryOperatorExpression o = other as UnaryOperatorExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UncheckedExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// unchecked(Expression)
/// </summary>
public class UncheckedExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class UncheckedExpression : Expression
{
public readonly static TokenRole UncheckedKeywordRole = new TokenRole("unchecked");
@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(expression, Roles.Expression);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitUncheckedExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitUncheckedExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUncheckedExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
UncheckedExpression o = other as UncheckedExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UndocumentedExpression.cs

@ -39,7 +39,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -39,7 +39,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Represents undocumented expressions.
/// </summary>
public class UndocumentedExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class UndocumentedExpression : Expression
{
public readonly static TokenRole ArglistKeywordRole = new TokenRole("__arglist");
public readonly static TokenRole RefvalueKeywordRole = new TokenRole("__refvalue");
@ -80,21 +81,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -80,21 +81,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RPar); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitUndocumentedExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitUndocumentedExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUndocumentedExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
UndocumentedExpression o = other as UndocumentedExpression;

18
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/WithInitializerExpression.cs

@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Expression with Initializer
/// </summary>
public class WithInitializerExpression : Expression
[DecompilerAstNode(hasNullNode: false)]
public partial class WithInitializerExpression : Expression
{
public readonly static TokenRole WithKeywordRole = new TokenRole("with");
public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole;
@ -42,21 +43,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -42,21 +43,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(InitializerRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitWithInitializerExpression(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitWithInitializerExpression(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitWithInitializerExpression(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return other is WithInitializerExpression o

18
ICSharpCode.Decompiler/CSharp/Syntax/FunctionPointerAstType.cs

@ -31,7 +31,8 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -31,7 +31,8 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class FunctionPointerAstType : AstType
[DecompilerAstNode(hasNullNode: false)]
public partial class FunctionPointerAstType : AstType
{
public static readonly TokenRole PointerRole = new TokenRole("*");
public static readonly Role<AstType> CallingConventionRole = new Role<AstType>("CallConv", AstType.Null);
@ -51,21 +52,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -51,21 +52,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Type, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitFunctionPointerType(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitFunctionPointerType(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitFunctionPointerType(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other is FunctionPointerAstType o

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Attribute.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Attribute(Arguments)
/// </summary>
public class Attribute : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class Attribute : AstNode
{
public override NodeType NodeType {
get {
@ -62,21 +63,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -62,21 +63,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitAttribute(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitAttribute(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAttribute(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
Attribute o = other as Attribute;

64
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/AttributeSection.cs

@ -30,54 +30,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,54 +30,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// [AttributeTarget: Attributes]
/// </summary>
public class AttributeSection : AstNode
[DecompilerAstNode(hasNullNode: false, hasPatternPlaceholder: true)]
public partial class AttributeSection : AstNode
{
#region PatternPlaceholder
public static implicit operator AttributeSection(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : AttributeSection, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get {
return NodeType.Unknown;
@ -114,21 +69,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -114,21 +69,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RBracket); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitAttributeSection(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitAttributeSection(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAttributeSection(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
AttributeSection o = other as AttributeSection;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs

@ -51,7 +51,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -51,7 +51,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
MultiLineDocumentation
}
public class Comment : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class Comment : AstNode
{
public override NodeType NodeType {
get {
@ -128,21 +129,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -128,21 +129,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.endLocation = endLocation;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitComment(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitComment(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitComment(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
Comment o = other as Comment;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Constraint.cs

@ -33,7 +33,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -33,7 +33,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <remarks>
/// new(), struct and class constraints are represented using a PrimitiveType "new", "struct" or "class"
/// </remarks>
public class Constraint : AstNode
[DecompilerAstNode(hasNullNode: true)]
public partial class Constraint : AstNode
{
public override NodeType NodeType {
get { return NodeType.Unknown; }
@ -58,21 +59,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -58,21 +59,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitConstraint(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitConstraint(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitConstraint(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
Constraint o = other as Constraint;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// delegate ReturnType Name&lt;TypeParameters&gt;(Parameters) where Constraints;
/// </summary>
public class DelegateDeclaration : EntityDeclaration
[DecompilerAstNode(hasNullNode: false)]
public partial class DelegateDeclaration : EntityDeclaration
{
public override NodeType NodeType {
get { return NodeType.TypeDeclaration; }
@ -65,21 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -65,21 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildrenByRole(Roles.Constraint); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitDelegateDeclaration(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitDelegateDeclaration(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDelegateDeclaration(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DelegateDeclaration o = other as DelegateDeclaration;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/ExternAliasDeclaration.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// extern alias IDENTIFIER;
/// </summary>
public class ExternAliasDeclaration : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class ExternAliasDeclaration : AstNode
{
public override NodeType NodeType {
get {
@ -68,21 +69,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -68,21 +69,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitExternAliasDeclaration(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitExternAliasDeclaration(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitExternAliasDeclaration(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as ExternAliasDeclaration;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/NamespaceDeclaration.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// namespace Name { Members }
/// </summary>
public class NamespaceDeclaration : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class NamespaceDeclaration : AstNode
{
public static readonly Role<AstNode> MemberRole = SyntaxTree.MemberRole;
public static readonly Role<AstType> NamespaceNameRole = new Role<AstType>("NamespaceName", AstType.Null);
@ -135,21 +136,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -135,21 +136,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(child, MemberRole);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNamespaceDeclaration(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNamespaceDeclaration(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNamespaceDeclaration(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
NamespaceDeclaration o = other as NamespaceDeclaration;

24
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/PreProcessorDirective.cs

@ -46,7 +46,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -46,7 +46,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Line = 12
}
public class LinePreprocessorDirective : PreProcessorDirective
[DecompilerAstNode(hasNullNode: false)]
public partial class LinePreprocessorDirective : PreProcessorDirective
{
public int LineNumber {
get;
@ -67,7 +68,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -67,7 +68,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class PragmaWarningPreprocessorDirective : PreProcessorDirective
[DecompilerAstNode(hasNullNode: false)]
public partial class PragmaWarningPreprocessorDirective : PreProcessorDirective
{
public static readonly Role<PrimitiveExpression> WarningRole = new Role<PrimitiveExpression>("Warning", null);
@ -125,7 +127,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -125,7 +127,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class PreProcessorDirective : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class PreProcessorDirective : AstNode
{
public override NodeType NodeType {
get {
@ -178,21 +181,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -178,21 +181,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.Argument = argument;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPreProcessorDirective(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPreProcessorDirective(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPreProcessorDirective(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
PreProcessorDirective o = other as PreProcessorDirective;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs

@ -47,7 +47,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -47,7 +47,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// class Name&lt;TypeParameters&gt; : BaseTypes where Constraints;
/// </summary>
public class TypeDeclaration : EntityDeclaration
[DecompilerAstNode(hasNullNode: false)]
public partial class TypeDeclaration : EntityDeclaration
{
public override NodeType NodeType {
get { return NodeType.TypeDeclaration; }
@ -132,21 +133,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -132,21 +133,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RBrace); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitTypeDeclaration(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitTypeDeclaration(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeDeclaration(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
TypeDeclaration o = other as TypeDeclaration;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs

@ -27,7 +27,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -27,7 +27,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Note: mirroring the C# syntax, constraints are not part of the type parameter declaration, but belong
/// to the parent type or method.
/// </summary>
public class TypeParameterDeclaration : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class TypeParameterDeclaration : AstNode
{
public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole;
public static readonly TokenRole OutVarianceKeywordRole = new TokenRole("out");
@ -89,21 +90,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -89,21 +90,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Name = name;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitTypeParameterDeclaration(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitTypeParameterDeclaration(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeParameterDeclaration(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
TypeParameterDeclaration o = other as TypeParameterDeclaration;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingAliasDeclaration.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// using Alias = Import;
/// </summary>
public class UsingAliasDeclaration : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class UsingAliasDeclaration : AstNode
{
public static readonly TokenRole UsingKeywordRole = new TokenRole("using");
public static readonly Role<Identifier> AliasRole = new Role<Identifier>("Alias", Identifier.Null);
@ -84,21 +85,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -84,21 +85,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(import, ImportRole);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitUsingAliasDeclaration(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitUsingAliasDeclaration(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUsingAliasDeclaration(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
UsingAliasDeclaration o = other as UsingAliasDeclaration;

18
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingDeclaration.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// using Import;
/// </summary>
public class UsingDeclaration : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class UsingDeclaration : AstNode
{
public static readonly TokenRole UsingKeywordRole = new TokenRole("using");
public static readonly Role<AstType> ImportRole = new Role<AstType>("Import", AstType.Null);
@ -100,21 +101,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -100,21 +101,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(import, ImportRole);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitUsingDeclaration(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitUsingDeclaration(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUsingDeclaration(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
UsingDeclaration o = other as UsingDeclaration;

468
ICSharpCode.Decompiler/CSharp/Syntax/IAstVisitor.cs

@ -1,468 +0,0 @@ @@ -1,468 +0,0 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
/// <summary>
/// AST visitor.
/// </summary>
public interface IAstVisitor
{
void VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
void VisitAsExpression(AsExpression asExpression);
void VisitAssignmentExpression(AssignmentExpression assignmentExpression);
void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
void VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
void VisitCastExpression(CastExpression castExpression);
void VisitCheckedExpression(CheckedExpression checkedExpression);
void VisitConditionalExpression(ConditionalExpression conditionalExpression);
void VisitDeclarationExpression(DeclarationExpression declarationExpression);
void VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression);
void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
void VisitDirectionExpression(DirectionExpression directionExpression);
void VisitIdentifierExpression(IdentifierExpression identifierExpression);
void VisitIndexerExpression(IndexerExpression indexerExpression);
void VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression);
void VisitInvocationExpression(InvocationExpression invocationExpression);
void VisitIsExpression(IsExpression isExpression);
void VisitLambdaExpression(LambdaExpression lambdaExpression);
void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
void VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
void VisitNamedExpression(NamedExpression namedExpression);
void VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
void VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
void VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression);
void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
void VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
void VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
void VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
void VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
void VisitThrowExpression(ThrowExpression throwExpression);
void VisitTupleExpression(TupleExpression tupleExpression);
void VisitTypeOfExpression(TypeOfExpression typeOfExpression);
void VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
void VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
void VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
void VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression);
void VisitQueryExpression(QueryExpression queryExpression);
void VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
void VisitQueryFromClause(QueryFromClause queryFromClause);
void VisitQueryLetClause(QueryLetClause queryLetClause);
void VisitQueryWhereClause(QueryWhereClause queryWhereClause);
void VisitQueryJoinClause(QueryJoinClause queryJoinClause);
void VisitQueryOrderClause(QueryOrderClause queryOrderClause);
void VisitQueryOrdering(QueryOrdering queryOrdering);
void VisitQuerySelectClause(QuerySelectClause querySelectClause);
void VisitQueryGroupClause(QueryGroupClause queryGroupClause);
void VisitAttribute(Attribute attribute);
void VisitAttributeSection(AttributeSection attributeSection);
void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
void VisitTypeDeclaration(TypeDeclaration typeDeclaration);
void VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
void VisitUsingDeclaration(UsingDeclaration usingDeclaration);
void VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
void VisitBlockStatement(BlockStatement blockStatement);
void VisitBreakStatement(BreakStatement breakStatement);
void VisitCheckedStatement(CheckedStatement checkedStatement);
void VisitContinueStatement(ContinueStatement continueStatement);
void VisitDoWhileStatement(DoWhileStatement doWhileStatement);
void VisitEmptyStatement(EmptyStatement emptyStatement);
void VisitExpressionStatement(ExpressionStatement expressionStatement);
void VisitFixedStatement(FixedStatement fixedStatement);
void VisitForeachStatement(ForeachStatement foreachStatement);
void VisitForStatement(ForStatement forStatement);
void VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
void VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
void VisitGotoStatement(GotoStatement gotoStatement);
void VisitIfElseStatement(IfElseStatement ifElseStatement);
void VisitLabelStatement(LabelStatement labelStatement);
void VisitLockStatement(LockStatement lockStatement);
void VisitReturnStatement(ReturnStatement returnStatement);
void VisitSwitchStatement(SwitchStatement switchStatement);
void VisitSwitchSection(SwitchSection switchSection);
void VisitCaseLabel(CaseLabel caseLabel);
void VisitSwitchExpression(SwitchExpression switchExpression);
void VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection);
void VisitThrowStatement(ThrowStatement throwStatement);
void VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
void VisitCatchClause(CatchClause catchClause);
void VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
void VisitUnsafeStatement(UnsafeStatement unsafeStatement);
void VisitUsingStatement(UsingStatement usingStatement);
void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
void VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement);
void VisitWhileStatement(WhileStatement whileStatement);
void VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
void VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
void VisitAccessor(Accessor accessor);
void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
void VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
void VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
void VisitEventDeclaration(EventDeclaration eventDeclaration);
void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
void VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
void VisitMethodDeclaration(MethodDeclaration methodDeclaration);
void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
void VisitVariableInitializer(VariableInitializer variableInitializer);
void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
void VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
void VisitSyntaxTree(SyntaxTree syntaxTree);
void VisitSimpleType(SimpleType simpleType);
void VisitMemberType(MemberType memberType);
void VisitTupleType(TupleAstType tupleType);
void VisitTupleTypeElement(TupleTypeElement tupleTypeElement);
void VisitFunctionPointerType(FunctionPointerAstType functionPointerType);
void VisitInvocationType(InvocationAstType invocationType);
void VisitComposedType(ComposedType composedType);
void VisitArraySpecifier(ArraySpecifier arraySpecifier);
void VisitPrimitiveType(PrimitiveType primitiveType);
void VisitComment(Comment comment);
void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
void VisitDocumentationReference(DocumentationReference documentationReference);
void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
void VisitConstraint(Constraint constraint);
void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
void VisitIdentifier(Identifier identifier);
void VisitInterpolation(Interpolation interpolation);
void VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText);
void VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation);
void VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation);
void VisitNullNode(AstNode nullNode);
void VisitErrorNode(AstNode errorNode);
void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
}
/// <summary>
/// AST visitor.
/// </summary>
public interface IAstVisitor<out S>
{
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
S VisitAsExpression(AsExpression asExpression);
S VisitAssignmentExpression(AssignmentExpression assignmentExpression);
S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
S VisitCastExpression(CastExpression castExpression);
S VisitCheckedExpression(CheckedExpression checkedExpression);
S VisitConditionalExpression(ConditionalExpression conditionalExpression);
S VisitDeclarationExpression(DeclarationExpression declarationExpression);
S VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression);
S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
S VisitDirectionExpression(DirectionExpression directionExpression);
S VisitIdentifierExpression(IdentifierExpression identifierExpression);
S VisitIndexerExpression(IndexerExpression indexerExpression);
S VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression);
S VisitInvocationExpression(InvocationExpression invocationExpression);
S VisitIsExpression(IsExpression isExpression);
S VisitLambdaExpression(LambdaExpression lambdaExpression);
S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
S VisitNamedExpression(NamedExpression namedExpression);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
S VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
S VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
S VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
S VisitThrowExpression(ThrowExpression throwExpression);
S VisitTupleExpression(TupleExpression tupleExpression);
S VisitTypeOfExpression(TypeOfExpression typeOfExpression);
S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
S VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
S VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression);
S VisitQueryExpression(QueryExpression queryExpression);
S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
S VisitQueryFromClause(QueryFromClause queryFromClause);
S VisitQueryLetClause(QueryLetClause queryLetClause);
S VisitQueryWhereClause(QueryWhereClause queryWhereClause);
S VisitQueryJoinClause(QueryJoinClause queryJoinClause);
S VisitQueryOrderClause(QueryOrderClause queryOrderClause);
S VisitQueryOrdering(QueryOrdering queryOrdering);
S VisitQuerySelectClause(QuerySelectClause querySelectClause);
S VisitQueryGroupClause(QueryGroupClause queryGroupClause);
S VisitAttribute(Attribute attribute);
S VisitAttributeSection(AttributeSection attributeSection);
S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
S VisitTypeDeclaration(TypeDeclaration typeDeclaration);
S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
S VisitUsingDeclaration(UsingDeclaration usingDeclaration);
S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
S VisitBlockStatement(BlockStatement blockStatement);
S VisitBreakStatement(BreakStatement breakStatement);
S VisitCheckedStatement(CheckedStatement checkedStatement);
S VisitContinueStatement(ContinueStatement continueStatement);
S VisitDoWhileStatement(DoWhileStatement doWhileStatement);
S VisitEmptyStatement(EmptyStatement emptyStatement);
S VisitExpressionStatement(ExpressionStatement expressionStatement);
S VisitFixedStatement(FixedStatement fixedStatement);
S VisitForeachStatement(ForeachStatement foreachStatement);
S VisitForStatement(ForStatement forStatement);
S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
S VisitGotoStatement(GotoStatement gotoStatement);
S VisitIfElseStatement(IfElseStatement ifElseStatement);
S VisitLabelStatement(LabelStatement labelStatement);
S VisitLockStatement(LockStatement lockStatement);
S VisitReturnStatement(ReturnStatement returnStatement);
S VisitSwitchStatement(SwitchStatement switchStatement);
S VisitSwitchSection(SwitchSection switchSection);
S VisitCaseLabel(CaseLabel caseLabel);
S VisitSwitchExpression(SwitchExpression switchExpression);
S VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection);
S VisitThrowStatement(ThrowStatement throwStatement);
S VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
S VisitCatchClause(CatchClause catchClause);
S VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
S VisitUnsafeStatement(UnsafeStatement unsafeStatement);
S VisitUsingStatement(UsingStatement usingStatement);
S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
S VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement);
S VisitWhileStatement(WhileStatement whileStatement);
S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
S VisitAccessor(Accessor accessor);
S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
S VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
S VisitEventDeclaration(EventDeclaration eventDeclaration);
S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
S VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
S VisitMethodDeclaration(MethodDeclaration methodDeclaration);
S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
S VisitVariableInitializer(VariableInitializer variableInitializer);
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
S VisitSyntaxTree(SyntaxTree syntaxTree);
S VisitSimpleType(SimpleType simpleType);
S VisitMemberType(MemberType memberType);
S VisitTupleType(TupleAstType tupleType);
S VisitTupleTypeElement(TupleTypeElement tupleTypeElement);
S VisitFunctionPointerType(FunctionPointerAstType functionPointerType);
S VisitInvocationType(InvocationAstType invocationType);
S VisitComposedType(ComposedType composedType);
S VisitArraySpecifier(ArraySpecifier arraySpecifier);
S VisitPrimitiveType(PrimitiveType primitiveType);
S VisitComment(Comment comment);
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
S VisitDocumentationReference(DocumentationReference documentationReference);
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
S VisitConstraint(Constraint constraint);
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
S VisitIdentifier(Identifier identifier);
S VisitInterpolation(Interpolation interpolation);
S VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText);
S VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation);
S VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation);
S VisitNullNode(AstNode nullNode);
S VisitErrorNode(AstNode errorNode);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
}
/// <summary>
/// AST visitor.
/// </summary>
public interface IAstVisitor<in T, out S>
{
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, T data);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data);
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data);
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data);
S VisitAsExpression(AsExpression asExpression, T data);
S VisitAssignmentExpression(AssignmentExpression assignmentExpression, T data);
S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, T data);
S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, T data);
S VisitCastExpression(CastExpression castExpression, T data);
S VisitCheckedExpression(CheckedExpression checkedExpression, T data);
S VisitConditionalExpression(ConditionalExpression conditionalExpression, T data);
S VisitDeclarationExpression(DeclarationExpression declarationExpression, T data);
S VisitRecursivePatternExpression(RecursivePatternExpression recursivePatternExpression, T data);
S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, T data);
S VisitDirectionExpression(DirectionExpression directionExpression, T data);
S VisitIdentifierExpression(IdentifierExpression identifierExpression, T data);
S VisitIndexerExpression(IndexerExpression indexerExpression, T data);
S VisitInterpolatedStringExpression(InterpolatedStringExpression interpolatedStringExpression, T data);
S VisitInvocationExpression(InvocationExpression invocationExpression, T data);
S VisitIsExpression(IsExpression isExpression, T data);
S VisitLambdaExpression(LambdaExpression lambdaExpression, T data);
S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, T data);
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data);
S VisitNamedExpression(NamedExpression namedExpression, T data);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data);
S VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression, T data);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data);
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data);
S VisitSizeOfExpression(SizeOfExpression sizeOfExpression, T data);
S VisitStackAllocExpression(StackAllocExpression stackAllocExpression, T data);
S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data);
S VisitThrowExpression(ThrowExpression throwExpression, T data);
S VisitTupleExpression(TupleExpression tupleExpression, T data);
S VisitTypeOfExpression(TypeOfExpression typeOfExpression, T data);
S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data);
S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data);
S VisitUncheckedExpression(UncheckedExpression uncheckedExpression, T data);
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, T data);
S VisitWithInitializerExpression(WithInitializerExpression withInitializerExpression, T data);
S VisitQueryExpression(QueryExpression queryExpression, T data);
S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, T data);
S VisitQueryFromClause(QueryFromClause queryFromClause, T data);
S VisitQueryLetClause(QueryLetClause queryLetClause, T data);
S VisitQueryWhereClause(QueryWhereClause queryWhereClause, T data);
S VisitQueryJoinClause(QueryJoinClause queryJoinClause, T data);
S VisitQueryOrderClause(QueryOrderClause queryOrderClause, T data);
S VisitQueryOrdering(QueryOrdering queryOrdering, T data);
S VisitQuerySelectClause(QuerySelectClause querySelectClause, T data);
S VisitQueryGroupClause(QueryGroupClause queryGroupClause, T data);
S VisitAttribute(Attribute attribute, T data);
S VisitAttributeSection(AttributeSection attributeSection, T data);
S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, T data);
S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, T data);
S VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data);
S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration, T data);
S VisitUsingDeclaration(UsingDeclaration usingDeclaration, T data);
S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data);
S VisitBlockStatement(BlockStatement blockStatement, T data);
S VisitBreakStatement(BreakStatement breakStatement, T data);
S VisitCheckedStatement(CheckedStatement checkedStatement, T data);
S VisitContinueStatement(ContinueStatement continueStatement, T data);
S VisitDoWhileStatement(DoWhileStatement doWhileStatement, T data);
S VisitEmptyStatement(EmptyStatement emptyStatement, T data);
S VisitExpressionStatement(ExpressionStatement expressionStatement, T data);
S VisitFixedStatement(FixedStatement fixedStatement, T data);
S VisitForeachStatement(ForeachStatement foreachStatement, T data);
S VisitForStatement(ForStatement forStatement, T data);
S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, T data);
S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, T data);
S VisitGotoStatement(GotoStatement gotoStatement, T data);
S VisitIfElseStatement(IfElseStatement ifElseStatement, T data);
S VisitLabelStatement(LabelStatement labelStatement, T data);
S VisitLockStatement(LockStatement lockStatement, T data);
S VisitReturnStatement(ReturnStatement returnStatement, T data);
S VisitSwitchStatement(SwitchStatement switchStatement, T data);
S VisitSwitchSection(SwitchSection switchSection, T data);
S VisitCaseLabel(CaseLabel caseLabel, T data);
S VisitSwitchExpression(SwitchExpression switchExpression, T data);
S VisitSwitchExpressionSection(SwitchExpressionSection switchExpressionSection, T data);
S VisitThrowStatement(ThrowStatement throwStatement, T data);
S VisitTryCatchStatement(TryCatchStatement tryCatchStatement, T data);
S VisitCatchClause(CatchClause catchClause, T data);
S VisitUncheckedStatement(UncheckedStatement uncheckedStatement, T data);
S VisitUnsafeStatement(UnsafeStatement unsafeStatement, T data);
S VisitUsingStatement(UsingStatement usingStatement, T data);
S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, T data);
S VisitLocalFunctionDeclarationStatement(LocalFunctionDeclarationStatement localFunctionDeclarationStatement, T data);
S VisitWhileStatement(WhileStatement whileStatement, T data);
S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, T data);
S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement, T data);
S VisitAccessor(Accessor accessor, T data);
S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, T data);
S VisitConstructorInitializer(ConstructorInitializer constructorInitializer, T data);
S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, T data);
S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, T data);
S VisitEventDeclaration(EventDeclaration eventDeclaration, T data);
S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration, T data);
S VisitFieldDeclaration(FieldDeclaration fieldDeclaration, T data);
S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, T data);
S VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data);
S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, T data);
S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data);
S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data);
S VisitVariableInitializer(VariableInitializer variableInitializer, T data);
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data);
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data);
S VisitSyntaxTree(SyntaxTree syntaxTree, T data);
S VisitSimpleType(SimpleType simpleType, T data);
S VisitMemberType(MemberType memberType, T data);
S VisitTupleType(TupleAstType tupleType, T data);
S VisitTupleTypeElement(TupleTypeElement tupleTypeElement, T data);
S VisitFunctionPointerType(FunctionPointerAstType functionPointerType, T data);
S VisitInvocationType(InvocationAstType invocationType, T data);
S VisitComposedType(ComposedType composedType, T data);
S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data);
S VisitPrimitiveType(PrimitiveType primitiveType, T data);
S VisitComment(Comment comment, T data);
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data);
S VisitDocumentationReference(DocumentationReference documentationReference, T data);
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data);
S VisitConstraint(Constraint constraint, T data);
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, T data);
S VisitIdentifier(Identifier identifier, T data);
S VisitInterpolation(Interpolation interpolation, T data);
S VisitInterpolatedStringText(InterpolatedStringText interpolatedStringText, T data);
S VisitSingleVariableDesignation(SingleVariableDesignation singleVariableDesignation, T data);
S VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignation parenthesizedVariableDesignation, T data);
S VisitNullNode(AstNode nullNode, T data);
S VisitErrorNode(AstNode errorNode, T data);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data);
}
}

48
ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs

@ -28,38 +28,9 @@ using System; @@ -28,38 +28,9 @@ using System;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class Identifier : AstNode
[DecompilerAstNode(hasNullNode: true)]
public partial class Identifier : AstNode
{
public new static readonly Identifier Null = new NullIdentifier();
sealed class NullIdentifier : Identifier
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
public override NodeType NodeType {
get {
return NodeType.Token;
@ -149,21 +120,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -149,21 +120,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return new Identifier(name, location);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitIdentifier(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitIdentifier(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIdentifier(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
Identifier o = other as Identifier;

20
ICSharpCode.Decompiler/CSharp/Syntax/InvocationAstType.cs

@ -17,8 +17,6 @@ @@ -17,8 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
@ -29,7 +27,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -29,7 +27,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// BaseType "(" Argument { "," Argument } ")"
/// </summary>
public class InvocationAstType : AstType
[DecompilerAstNode(hasNullNode: false)]
public partial class InvocationAstType : AstType
{
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole(Roles.Expression); }
@ -40,21 +39,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -40,21 +39,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Type, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitInvocationType(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitInvocationType(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitInvocationType(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return other is InvocationAstType o

18
ICSharpCode.Decompiler/CSharp/Syntax/MemberType.cs

@ -32,7 +32,8 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -32,7 +32,8 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class MemberType : AstType
[DecompilerAstNode(hasNullNode: false)]
public partial class MemberType : AstType
{
public static readonly Role<AstType> TargetRole = new Role<AstType>("Target", AstType.Null);
@ -97,21 +98,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -97,21 +98,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitMemberType(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitMemberType(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitMemberType(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
MemberType o = other as MemberType;

10
ICSharpCode.Decompiler/CSharp/Syntax/IdentifierExpressionBackreference.cs → ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/IdentifierExpressionBackreference.cs

@ -19,12 +19,12 @@ @@ -19,12 +19,12 @@
using System;
using System.Linq;
namespace ICSharpCode.Decompiler.CSharp.Syntax
namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
{
/// <summary>
/// Matches identifier expressions that have the same identifier as the referenced variable/type definition/method definition.
/// </summary>
public class IdentifierExpressionBackreference : PatternMatching.Pattern
public class IdentifierExpressionBackreference : Pattern
{
readonly string referencedGroupName;
@ -39,12 +39,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -39,12 +39,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.referencedGroupName = referencedGroupName;
}
public override bool DoMatch(PatternMatching.INode other, PatternMatching.Match match)
public override bool DoMatch(INode other, Match match)
{
IdentifierExpression ident = other as IdentifierExpression;
var ident = other as IdentifierExpression;
if (ident == null || ident.TypeArguments.Any())
return false;
AstNode referenced = (AstNode)match.Get(referencedGroupName).Last();
var referenced = (AstNode)match.Get(referencedGroupName).Last();
if (referenced == null)
return false;
return ident.Identifier == referenced.GetChildByRole(Roles.Identifier).Name;

18
ICSharpCode.Decompiler/CSharp/Syntax/PrimitiveType.cs

@ -33,7 +33,8 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation; @@ -33,7 +33,8 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class PrimitiveType : AstType
[DecompilerAstNode(hasNullNode: false)]
public partial class PrimitiveType : AstType
{
TextLocation location;
string keyword = string.Empty;
@ -85,21 +86,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -85,21 +86,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPrimitiveType(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPrimitiveType(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPrimitiveType(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
PrimitiveType o = other as PrimitiveType;

9
ICSharpCode.Decompiler/CSharp/Syntax/Role.cs

@ -88,15 +88,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -88,15 +88,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return node is T;
}
[Obsolete("Use the other overload explicitly specifying the nullObject.")]
public Role(string name)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
this.name = name;
this.nullObject = null!;
}
public Role(string name, T nullObject)
{
this.name = name ?? throw new ArgumentNullException(nameof(name));

56
ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs

@ -32,46 +32,9 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -32,46 +32,9 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class SimpleType : AstType
[DecompilerAstNode(hasNullNode: true)]
public partial class SimpleType : AstType
{
#region Null
public new static readonly SimpleType Null = new NullSimpleType();
sealed class NullSimpleType : SimpleType
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider)
{
return SpecialType.UnknownType;
}
}
#endregion
public SimpleType()
{
}
@ -126,21 +89,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -126,21 +89,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildrenByRole(Roles.TypeArgument); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitSimpleType(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitSimpleType(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSimpleType(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SimpleType o = other as SimpleType;

96
ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs

@ -31,88 +31,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -31,88 +31,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// { Statements }
/// </summary>
public class BlockStatement : Statement, IEnumerable<Statement>
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public partial class BlockStatement : Statement, IEnumerable<Statement>
{
public static readonly Role<Statement> StatementRole = new Role<Statement>("Statement", Statement.Null);
#region Null
public static readonly new BlockStatement Null = new NullBlockStatement();
sealed class NullBlockStatement : BlockStatement
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
#region PatternPlaceholder
public static implicit operator BlockStatement(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : BlockStatement, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public CSharpTokenNode LBraceToken {
get { return GetChildByRole(Roles.LBrace); }
}
@ -125,21 +48,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -125,21 +48,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RBrace); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitBlockStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitBlockStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBlockStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
BlockStatement o = other as BlockStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/BreakStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// break;
/// </summary>
public class BreakStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class BreakStatement : Statement
{
public static readonly TokenRole BreakKeywordRole = new TokenRole("break");
@ -42,21 +43,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -42,21 +43,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitBreakStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitBreakStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBreakStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
BreakStatement o = other as BreakStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/CheckedStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// checked BodyBlock
/// </summary>
public class CheckedStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class CheckedStatement : Statement
{
public static readonly TokenRole CheckedKeywordRole = new TokenRole("checked");
@ -52,21 +53,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -52,21 +53,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(body, Roles.Body);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitCheckedStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitCheckedStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCheckedStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CheckedStatement o = other as CheckedStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ContinueStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// continue;
/// </summary>
public class ContinueStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class ContinueStatement : Statement
{
public static readonly TokenRole ContinueKeywordRole = new TokenRole("continue");
@ -42,21 +43,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -42,21 +43,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitContinueStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitContinueStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitContinueStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ContinueStatement o = other as ContinueStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/DoWhileStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// "do EmbeddedStatement while(Condition);"
/// </summary>
public class DoWhileStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class DoWhileStatement : Statement
{
public static readonly TokenRole DoKeywordRole = new TokenRole("do");
public static readonly TokenRole WhileKeywordRole = new TokenRole("while");
@ -65,21 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -65,21 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitDoWhileStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitDoWhileStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDoWhileStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DoWhileStatement o = other as DoWhileStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/EmptyStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// ;
/// </summary>
public class EmptyStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class EmptyStatement : Statement
{
public TextLocation Location {
get;
@ -49,21 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -49,21 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitEmptyStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitEmptyStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitEmptyStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
EmptyStatement o = other as EmptyStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ExpressionStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Expression;
/// </summary>
public class ExpressionStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class ExpressionStatement : Statement
{
public Expression Expression {
get { return GetChildByRole(Roles.Expression); }
@ -41,21 +42,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -41,21 +42,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitExpressionStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitExpressionStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitExpressionStatement(this, data);
}
public ExpressionStatement()
{
}

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/FixedStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// fixed (Type Variables) EmbeddedStatement
/// </summary>
public class FixedStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class FixedStatement : Statement
{
public static readonly TokenRole FixedKeywordRole = new TokenRole("fixed");
@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.EmbeddedStatement, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitFixedStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitFixedStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitFixedStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
FixedStatement o = other as FixedStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// for (Initializers; Condition; Iterators) EmbeddedStatement
/// </summary>
public class ForStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class ForStatement : Statement
{
public static readonly TokenRole ForKeywordRole = new TokenRole("for");
public readonly static Role<Statement> InitializerRole = new Role<Statement>("Initializer", Statement.Null);
@ -71,21 +72,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -71,21 +72,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.EmbeddedStatement, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitForStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitForStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitForStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ForStatement o = other as ForStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForeachStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// foreach (Type VariableName in InExpression) EmbeddedStatement
/// </summary>
public class ForeachStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class ForeachStatement : Statement
{
public static readonly TokenRole AwaitRole = UnaryOperatorExpression.AwaitRole;
public static readonly TokenRole ForeachKeywordRole = new TokenRole("foreach");
@ -81,21 +82,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -81,21 +82,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.EmbeddedStatement, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitForeachStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitForeachStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitForeachStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ForeachStatement o = other as ForeachStatement;

54
ICSharpCode.Decompiler/CSharp/Syntax/Statements/GotoStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// "goto Label;"
/// </summary>
public class GotoStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class GotoStatement : Statement
{
public static readonly TokenRole GotoKeywordRole = new TokenRole("goto");
@ -63,21 +64,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -63,21 +64,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitGotoStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitGotoStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitGotoStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
GotoStatement o = other as GotoStatement;
@ -88,7 +74,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -88,7 +74,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// or "goto case LabelExpression;"
/// </summary>
public class GotoCaseStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class GotoCaseStatement : Statement
{
public static readonly TokenRole GotoKeywordRole = new TokenRole("goto");
public static readonly TokenRole CaseKeywordRole = new TokenRole("case");
@ -113,21 +100,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -113,21 +100,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitGotoCaseStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitGotoCaseStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitGotoCaseStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
GotoCaseStatement o = other as GotoCaseStatement;
@ -138,7 +110,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -138,7 +110,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// or "goto default;"
/// </summary>
public class GotoDefaultStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class GotoDefaultStatement : Statement
{
public static readonly TokenRole GotoKeywordRole = new TokenRole("goto");
public static readonly TokenRole DefaultKeywordRole = new TokenRole("default");
@ -155,21 +128,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -155,21 +128,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Semicolon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitGotoDefaultStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitGotoDefaultStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitGotoDefaultStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
GotoDefaultStatement o = other as GotoDefaultStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/IfElseStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// if (Condition) TrueStatement else FalseStatement
/// </summary>
public class IfElseStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class IfElseStatement : Statement
{
public readonly static TokenRole IfKeywordRole = new TokenRole("if");
public readonly static Role<Expression> ConditionRole = Roles.Condition;
@ -69,21 +70,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -69,21 +70,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(FalseRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitIfElseStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitIfElseStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIfElseStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
IfElseStatement o = other as IfElseStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/LabelStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// Label:
/// </summary>
public class LabelStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class LabelStatement : Statement
{
public string Label {
get {
@ -50,21 +51,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -50,21 +51,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Colon); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitLabelStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitLabelStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitLabelStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
LabelStatement o = other as LabelStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/LocalFunctionDeclarationStatement.cs

@ -20,7 +20,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching; @@ -20,7 +20,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public class LocalFunctionDeclarationStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class LocalFunctionDeclarationStatement : Statement
{
public static readonly Role<MethodDeclaration> MethodDeclarationRole = new Role<MethodDeclaration>("Method", null);
@ -34,21 +35,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -34,21 +35,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(methodDeclaration, MethodDeclarationRole);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitLocalFunctionDeclarationStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitLocalFunctionDeclarationStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitLocalFunctionDeclarationStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return other is LocalFunctionDeclarationStatement o && Declaration.DoMatch(o.Declaration, match);

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/LockStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// lock (Expression) EmbeddedStatement;
/// </summary>
public class LockStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class LockStatement : Statement
{
public static readonly TokenRole LockKeywordRole = new TokenRole("lock");
@ -56,21 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -56,21 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.EmbeddedStatement, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitLockStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitLockStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitLockStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
LockStatement o = other as LockStatement;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ReturnStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// return Expression;
/// </summary>
public class ReturnStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class ReturnStatement : Statement
{
public static readonly TokenRole ReturnKeywordRole = new TokenRole("return");
@ -56,21 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -56,21 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(returnExpression, Roles.Expression);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitReturnStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitReturnStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitReturnStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ReturnStatement o = other as ReturnStatement;

82
ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs

@ -27,87 +27,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -27,87 +27,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// This class is useful even though it doesn't provide any additional functionality:
/// It can be used to communicate more information in APIs, e.g. "this subnode will always be a statement"
/// </remarks>
public abstract class Statement : AstNode
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class Statement : AstNode
{
#region Null
public new static readonly Statement Null = new NullStatement();
sealed class NullStatement : Statement
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
#region PatternPlaceholder
public static implicit operator Statement(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : Statement, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public new Statement Clone()
{
return (Statement)base.Clone();

100
ICSharpCode.Decompiler/CSharp/Syntax/Statements/SwitchStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// switch (Expression) { SwitchSections }
/// </summary>
public class SwitchStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class SwitchStatement : Statement
{
public static readonly TokenRole SwitchKeywordRole = new TokenRole("switch");
public static readonly Role<SwitchSection> SwitchSectionRole = new Role<SwitchSection>("SwitchSection", null);
@ -64,21 +65,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -64,21 +65,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.RBrace); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitSwitchStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitSwitchStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSwitchStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SwitchStatement o = other as SwitchStatement;
@ -86,54 +72,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -86,54 +72,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class SwitchSection : AstNode
{
#region PatternPlaceholder
public static implicit operator SwitchSection(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : SwitchSection, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
[DecompilerAstNode(hasNullNode: false, hasPatternPlaceholder: true)]
public partial class SwitchSection : AstNode
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public static readonly Role<CaseLabel> CaseLabelRole = new Role<CaseLabel>("CaseLabel", null);
public override NodeType NodeType {
@ -150,21 +91,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -150,21 +91,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildrenByRole(Roles.EmbeddedStatement); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitSwitchSection(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitSwitchSection(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSwitchSection(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SwitchSection o = other as SwitchSection;
@ -172,7 +98,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -172,7 +98,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public class CaseLabel : AstNode
[DecompilerAstNode(hasNullNode: false)]
public partial class CaseLabel : AstNode
{
public static readonly TokenRole CaseKeywordRole = new TokenRole("case");
public static readonly TokenRole DefaultKeywordRole = new TokenRole("default");
@ -204,21 +131,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -204,21 +131,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.Expression = expression;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitCaseLabel(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitCaseLabel(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCaseLabel(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CaseLabel o = other as CaseLabel;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ThrowStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// throw Expression;
/// </summary>
public class ThrowStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class ThrowStatement : Statement
{
public static readonly TokenRole ThrowKeywordRole = new TokenRole("throw");
@ -56,21 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -56,21 +57,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(expression, Roles.Expression);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitThrowStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitThrowStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitThrowStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ThrowStatement o = other as ThrowStatement;

115
ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// try TryBlock CatchClauses finally FinallyBlock
/// </summary>
public class TryCatchStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class TryCatchStatement : Statement
{
public static readonly TokenRole TryKeywordRole = new TokenRole("try");
public static readonly Role<BlockStatement> TryBlockRole = new Role<BlockStatement>("TryBlock", BlockStatement.Null);
@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -60,21 +61,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(FinallyBlockRole, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitTryCatchStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitTryCatchStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTryCatchStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
TryCatchStatement o = other as TryCatchStatement;
@ -85,7 +71,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -85,7 +71,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// catch (Type VariableName) { Body }
/// </summary>
public class CatchClause : AstNode
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public partial class CatchClause : AstNode
{
public static readonly TokenRole CatchKeywordRole = new TokenRole("catch");
public static readonly TokenRole WhenKeywordRole = new TokenRole("when");
@ -93,85 +80,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -93,85 +80,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public static readonly TokenRole CondLPar = new TokenRole("(");
public static readonly TokenRole CondRPar = new TokenRole(")");
#region Null
public new static readonly CatchClause Null = new NullCatchClause();
sealed class NullCatchClause : CatchClause
{
public override bool IsNull {
get {
return true;
}
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNullNode(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNullNode(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
#region PatternPlaceholder
public static implicit operator CatchClause(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : CatchClause, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitPatternPlaceholder(this, child);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get {
return NodeType.Unknown;
@ -236,21 +144,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -236,21 +144,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
set { SetChildByRole(Roles.Body, value); }
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitCatchClause(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitCatchClause(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCatchClause(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CatchClause o = other as CatchClause;

18
ICSharpCode.Decompiler/CSharp/Syntax/Statements/UncheckedStatement.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary>
/// unchecked BodyBlock
/// </summary>
public class UncheckedStatement : Statement
[DecompilerAstNode(hasNullNode: false)]
public partial class UncheckedStatement : Statement
{
public static readonly TokenRole UncheckedKeywordRole = new TokenRole("unchecked");
@ -52,21 +53,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -52,21 +53,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(body, Roles.Body);
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitUncheckedStatement(this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitUncheckedStatement(this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUncheckedStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
UncheckedStatement o = other as UncheckedStatement;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save