diff --git a/Directory.Packages.props b/Directory.Packages.props
index 4aa51ddaf..822b0c4f0 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -14,8 +14,11 @@
+
+
+
diff --git a/ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs b/ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs
new file mode 100644
index 000000000..08b9c19d2
--- /dev/null
+++ b/ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs
@@ -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(IAstVisitor visitor)
+ {{
+ return visitor.VisitNullNode(this);
+ }}
+
+ public override S AcceptVisitor(IAstVisitor 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(IAstVisitor visitor)
+ {{
+ return visitor.VisitPatternPlaceholder(this, child);
+ }}
+
+ public override S AcceptVisitor(IAstVisitor 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(IAstVisitor visitor)
+ {{
+ return visitor.Visit{source.VisitMethodName}(this);
+ }}
+
+ public override S AcceptVisitor(IAstVisitor 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 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", "S", "");
+ WriteInterface("IAstVisitor", "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 : IEquatable>, IEnumerable
+ where T : IEquatable
+{
+ readonly T[] array;
+
+ public EquatableArray(T[] array)
+ {
+ this.array = array ?? throw new ArgumentNullException(nameof(array));
+ }
+
+ public bool Equals(EquatableArray other)
+ {
+ return other.array.AsSpan().SequenceEqual(this.array);
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return ((IEnumerable)array).GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return array.GetEnumerator();
+ }
+}
+
+static class EquatableArrayExtensions
+{
+ public static EquatableArray ToEquatableArray(this List array) where T : IEquatable
+ {
+ return new EquatableArray(array.ToArray());
+ }
+}
\ No newline at end of file
diff --git a/ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj b/ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj
new file mode 100644
index 000000000..fc882407c
--- /dev/null
+++ b/ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj
@@ -0,0 +1,16 @@
+
+
+
+ netstandard2.0
+ enable
+ enable
+ true
+ 12
+
+
+
+
+
+
+
+
diff --git a/ICSharpCode.Decompiler.Generators/IsExternalInit.cs b/ICSharpCode.Decompiler.Generators/IsExternalInit.cs
new file mode 100644
index 000000000..7bac4c969
--- /dev/null
+++ b/ICSharpCode.Decompiler.Generators/IsExternalInit.cs
@@ -0,0 +1,3 @@
+namespace System.Runtime.CompilerServices;
+
+class IsExternalInit { }
diff --git a/ICSharpCode.Decompiler.Generators/RoslynHelpers.cs b/ICSharpCode.Decompiler.Generators/RoslynHelpers.cs
new file mode 100644
index 000000000..fa4747f76
--- /dev/null
+++ b/ICSharpCode.Decompiler.Generators/RoslynHelpers.cs
@@ -0,0 +1,32 @@
+using Microsoft.CodeAnalysis;
+
+namespace ICSharpCode.Decompiler.Generators;
+
+public static class RoslynHelpers
+{
+ public static IEnumerable 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;
+ }
+}
diff --git a/ICSharpCode.Decompiler.Generators/TreeTraversal.cs b/ICSharpCode.Decompiler.Generators/TreeTraversal.cs
new file mode 100644
index 000000000..4c194383a
--- /dev/null
+++ b/ICSharpCode.Decompiler.Generators/TreeTraversal.cs
@@ -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;
+
+///
+/// Static helper methods for traversing trees.
+///
+internal static class TreeTraversal
+{
+ ///
+ /// Converts a tree data structure into a flat list by traversing it in pre-order.
+ ///
+ /// The root element of the tree.
+ /// The function that gets the children of an element.
+ /// Iterator that enumerates the tree structure in pre-order.
+ public static IEnumerable PreOrder(T root, Func?> recursion)
+ {
+ return PreOrder(new T[] { root }, recursion);
+ }
+
+ ///
+ /// Converts a tree data structure into a flat list by traversing it in pre-order.
+ ///
+ /// The root elements of the forest.
+ /// The function that gets the children of an element.
+ /// Iterator that enumerates the tree structure in pre-order.
+ public static IEnumerable PreOrder(IEnumerable input, Func?> recursion)
+ {
+ Stack> stack = new Stack>();
+ try
+ {
+ stack.Push(input.GetEnumerator());
+ while (stack.Count > 0)
+ {
+ while (stack.Peek().MoveNext())
+ {
+ T element = stack.Peek().Current;
+ yield return element;
+ IEnumerable? children = recursion(element);
+ if (children != null)
+ {
+ stack.Push(children.GetEnumerator());
+ }
+ }
+ stack.Pop().Dispose();
+ }
+ }
+ finally
+ {
+ while (stack.Count > 0)
+ {
+ stack.Pop().Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Converts a tree data structure into a flat list by traversing it in post-order.
+ ///
+ /// The root element of the tree.
+ /// The function that gets the children of an element.
+ /// Iterator that enumerates the tree structure in post-order.
+ public static IEnumerable PostOrder(T root, Func?> recursion)
+ {
+ return PostOrder(new T[] { root }, recursion);
+ }
+
+ ///
+ /// Converts a tree data structure into a flat list by traversing it in post-order.
+ ///
+ /// The root elements of the forest.
+ /// The function that gets the children of an element.
+ /// Iterator that enumerates the tree structure in post-order.
+ public static IEnumerable PostOrder(IEnumerable input, Func?> recursion)
+ {
+ Stack> stack = new Stack>();
+ try
+ {
+ stack.Push(input.GetEnumerator());
+ while (stack.Count > 0)
+ {
+ while (stack.Peek().MoveNext())
+ {
+ T element = stack.Peek().Current;
+ IEnumerable? 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();
+ }
+ }
+ }
+}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs b/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
index b11edf399..605f6b8e7 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
@@ -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 RootRole = new Role("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(IAstVisitor visitor)
- {
- return visitor.VisitNullNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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(IAstVisitor visitor)
- {
- return visitor.VisitPatternPlaceholder(this, child);
- }
-
- public override S AcceptVisitor(IAstVisitor 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;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs b/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs
index a8b8da53a..a8f5cdc97 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs
@@ -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
///
/// A type reference in the C# AST.
///
- 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(IAstVisitor visitor)
- {
- return visitor.VisitNullNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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(IAstVisitor visitor)
- {
- return visitor.VisitPatternPlaceholder(this, child);
- }
-
- public override S AcceptVisitor(IAstVisitor 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; }
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs b/ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs
index fbe31464d..d295a515b 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs
@@ -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;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs b/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs
index 6bbf8a546..e458f1fbc 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs
@@ -34,42 +34,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// In all non null c# token nodes the Role of a CSharpToken must be a TokenRole.
///
- 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(IAstVisitor visitor)
- {
- return visitor.VisitNullNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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
return string.Empty;
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitCSharpTokenNode(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitCSharpTokenNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitCSharpTokenNode(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CSharpTokenNode o = other as CSharpTokenNode;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs b/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs
index c042a2ca9..33ade4c83 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs
@@ -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 AttributeRole = EntityDeclaration.AttributeRole;
public static readonly TokenRole RefRole = new TokenRole("ref");
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitComposedType(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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
///
/// [,,,]
///
- 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
get { return GetChildByRole(Roles.RBracket); }
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitArraySpecifier(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitArraySpecifier(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitArraySpecifier(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ArraySpecifier o = other as ArraySpecifier;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs b/ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs
index 893f015fc..550e913ec 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs
@@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// Represents a 'cref' reference in XML documentation.
///
- public class DocumentationReference : AstNode
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class DocumentationReference : AstNode
{
public static readonly Role DeclaringTypeRole = new Role("DeclaringType", AstType.Null);
public static readonly Role ConversionOperatorReturnTypeRole = new Role("ConversionOperatorReturnType", AstType.Null);
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitDocumentationReference(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitDocumentationReference(this, data);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs
index 633073b36..964a4fd2a 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs
@@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// [async] delegate(Parameters) {Body}
///
- 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
public AnonymousMethodExpression(BlockStatement body, params ParameterDeclaration[] parameters) : this(body, (IEnumerable)parameters)
{
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitAnonymousMethodExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitAnonymousMethodExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs
index e74e2e1af..0160c3b25 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs
@@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// new { [ExpressionList] }
///
- 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
public AnonymousTypeCreateExpression(params Expression[] initializer) : this((IEnumerable)initializer)
{
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitAnonymousTypeCreateExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitAnonymousTypeCreateExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs
index e4314f001..de1a58ff7 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs
@@ -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
{
///
/// new Type[Dimensions]
///
- public class ArrayCreateExpression : Expression
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class ArrayCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole("new");
public readonly static Role AdditionalArraySpecifierRole = new Role("AdditionalArraySpecifier", null);
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitArrayCreateExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs
index f9ce09152..3702f18cb 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs
@@ -31,20 +31,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// { Elements }
///
- public class ArrayInitializerExpression : Expression
+ [DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
+ public partial class ArrayInitializerExpression : Expression
{
- ///
- /// 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).
- ///
- public virtual bool IsSingleElement {
- get {
- return false;
- }
- }
-
public ArrayInitializerExpression()
{
}
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitNullNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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
public CSharpTokenNode RBraceToken {
get { return GetChildByRole(Roles.RBrace); }
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitArrayInitializerExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitArrayInitializerExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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();
- }
- ///
- /// Single elements in array initializers are represented with this special class.
- ///
- 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(IAstVisitor visitor)
- {
- return visitor.VisitPatternPlaceholder(this, child);
- }
-
- public override S AcceptVisitor(IAstVisitor 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
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs
index b01fd4f86..13666c173 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs
@@ -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
{
///
/// Expression as TypeReference
///
- 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
AddChild(expression, Roles.Expression);
AddChild(type, Roles.Type);
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitAsExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitAsExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs
index 378b33bfa..56c4eba2a 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs
@@ -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
///
/// Left Operator= Right
///
- public class AssignmentExpression : Expression
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class AssignmentExpression : Expression
{
// reuse roles from BinaryOperatorExpression
public readonly static Role LeftRole = BinaryOperatorExpression.LeftRole;
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitAssignmentExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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)
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs
index 5084d0e04..ace2c05d9 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs
@@ -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
{
///
/// base
///
- 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
return new TextLocation(Location.Line, Location.Column + "base".Length);
}
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitBaseReferenceExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitBaseReferenceExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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;
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs
index 1386e1029..af73340e4 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs
@@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// Left Operator Right
///
- 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
set { SetChildByRole(RightRole, value); }
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitBinaryOperatorExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitBinaryOperatorExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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)
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs
index f3bd22ec2..b8d05a715 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs
@@ -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
{
///
/// (CastTo)Expression
///
- 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
AddChild(castToType, Roles.Type);
AddChild(expression, Roles.Expression);
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitCastExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitCastExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs
index baff6c51a..dacceb8c9 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs
@@ -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
{
///
/// checked(Expression)
///
- 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
{
AddChild(expression, Roles.Expression);
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitCheckedExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitCheckedExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs
index a1576e5cc..809312b9e 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs
@@ -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
{
///
/// Condition ? TrueExpression : FalseExpression
///
- public class ConditionalExpression : Expression
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class ConditionalExpression : Expression
{
public readonly static Role ConditionRole = Roles.Condition;
public readonly static TokenRole QuestionMarkRole = new TokenRole("?");
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitConditionalExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs
index 558456524..c24382f8d 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs
@@ -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
{
///
/// TypeName VariableDesignation
///
- 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
get { return GetChildByRole(Roles.VariableDesignationRole); }
set { SetChildByRole(Roles.VariableDesignationRole, value); }
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitDeclarationExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitDeclarationExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DecompilerAstNodeAttribute.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DecompilerAstNodeAttribute.cs
new file mode 100644
index 000000000..a0dd2b2ae
--- /dev/null
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DecompilerAstNodeAttribute.cs
@@ -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
+ {
+ }
+}
\ No newline at end of file
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs
index 372325a40..6e310505e 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs
@@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// default(Type)
///
- 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
{
AddChild(type, Roles.Type);
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitDefaultValueExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitDefaultValueExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs
index e92115530..9f07667ee 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs
@@ -38,7 +38,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// ref Expression
///
- 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
this.FieldDirection = direction;
AddChild(expression, Roles.Expression);
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitDirectionExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitDirectionExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs
index 89f9fcfdd..956ec76b7 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs
@@ -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
}
}
- public string Error {
- get;
- private set;
- }
-
public ErrorExpression()
{
}
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitErrorNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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;
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs
index c5d73352e..f73e50549 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs
@@ -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
/// 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"
///
- 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(IAstVisitor visitor)
- {
- return visitor.VisitNullNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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(IAstVisitor visitor)
- {
- return visitor.VisitPatternPlaceholder(this, child);
- }
-
- public override S AcceptVisitor(IAstVisitor 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;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs
index 76fc8c2a5..e6da3ddd6 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs
@@ -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
public AstNodeCollection TypeArguments {
get { return GetChildrenByRole(Roles.TypeArgument); }
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitIdentifierExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitIdentifierExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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);
- }
}
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs
index e688b2a74..3d3d01420 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs
@@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// Target[Arguments]
///
- 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
{
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitIndexerExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitIndexerExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitIndexerExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
IndexerExpression o = other as IndexerExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
index 562755a0a..b790676f5 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
@@ -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
Content.AddRange(content);
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitInterpolatedStringExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitInterpolatedStringExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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
}
}
- 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(IAstVisitor visitor)
- {
- return visitor.VisitNullNode(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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 Role = new Role("InterpolatedStringContent", Syntax.InterpolatedStringContent.Null);
public override NodeType NodeType => NodeType.Unknown;
@@ -90,7 +42,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// { Expression , Alignment : Suffix }
///
- 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
Suffix = suffix;
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitInterpolation(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitInterpolation(this);
- }
-
- public override S AcceptVisitor(IAstVisitor 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
}
}
- 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
Text = text;
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitInterpolatedStringText(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitInterpolatedStringText(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitInterpolatedStringText(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, Match match)
{
InterpolatedStringText o = other as InterpolatedStringText;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs
index 3ed91cefc..41e0c782a 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs
@@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// Target(Arguments)
///
- 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
get { return GetChildByRole(Roles.RPar); }
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitInvocationExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitInvocationExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitInvocationExpression(this, data);
- }
-
public InvocationExpression()
{
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs
index fa1bea0bc..5624ec68b 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs
@@ -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
{
///
/// Expression is Type
///
- 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
AddChild(type, Roles.Type);
}
-
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitIsExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitIsExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitIsExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
IsExpression o = other as IsExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs
index 8782aa1d8..2b49a1569 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs
@@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// [async] Parameters => Body
///
- public class LambdaExpression : Expression
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class LambdaExpression : Expression
{
public static readonly Role AttributeRole = new Role("Attribute", null);
public readonly static TokenRole AsyncModifierRole = new TokenRole("async");
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitLambdaExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitLambdaExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
LambdaExpression o = other as LambdaExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs
index fcda03b54..656710e61 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs
@@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// Target.MemberName
///
- 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
{
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitMemberReferenceExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitMemberReferenceExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitMemberReferenceExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
MemberReferenceExpression o = other as MemberReferenceExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs
index 5f3fb3627..cce206d08 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs
@@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Represents a named argument passed to a method or attribute.
/// name: expression
///
- public class NamedArgumentExpression : Expression
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class NamedArgumentExpression : Expression
{
public NamedArgumentExpression()
{
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitNamedArgumentExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitNamedArgumentExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
NamedArgumentExpression o = other as NamedArgumentExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs
index d8fe23df8..87d278d13 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs
@@ -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)].
///
- public class NamedExpression : Expression
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class NamedExpression : Expression
{
public NamedExpression()
{
@@ -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(IAstVisitor visitor)
- {
- return visitor.VisitNamedExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitNamedExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as NamedExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs
index ee67fb20f..a136fc800 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs
@@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// null
///
- 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
this.location = location;
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitNullReferenceExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitNullReferenceExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitNullReferenceExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
NullReferenceExpression o = other as NullReferenceExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs
index f559f6a89..c96b9428e 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs
@@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// new Type(Arguments) { Initializer }
///
- public class ObjectCreateExpression : Expression
+ [DecompilerAstNode(hasNullNode: false)]
+ public partial class ObjectCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole("new");
public readonly static Role InitializerRole = ArrayCreateExpression.InitializerRole;
@@ -82,21 +83,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitObjectCreateExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitObjectCreateExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitObjectCreateExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ObjectCreateExpression o = other as ObjectCreateExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs
index 022987e80..28fb3692d 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs
@@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// out type expression
///
- 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
this.Variable = new VariableInitializer(name);
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitOutVarDeclarationExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitOutVarDeclarationExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitOutVarDeclarationExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as OutVarDeclarationExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs
index b662ab3d4..cf17f350e 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs
@@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// ( Expression )
///
- 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
Expression = expr;
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitParenthesizedExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitParenthesizedExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitParenthesizedExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ParenthesizedExpression o = other as ParenthesizedExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs
index d678cdaf8..5417245d2 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs
@@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// Target->MemberName
///
- 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
get { return GetChildrenByRole(Roles.TypeArgument); }
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitPointerReferenceExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitPointerReferenceExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitPointerReferenceExpression(this, data);
- }
-
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
PointerReferenceExpression o = other as PointerReferenceExpression;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs
index a1e8fcc3b..153493737 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs
@@ -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
///
/// Represents a literal value.
///
- 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
this.format = format;
}
- public override void AcceptVisitor(IAstVisitor visitor)
- {
- visitor.VisitPrimitiveExpression(this);
- }
-
- public override T AcceptVisitor(IAstVisitor visitor)
- {
- return visitor.VisitPrimitiveExpression(this);
- }
-
- public override S AcceptVisitor(IAstVisitor visitor, T data)
- {
- return visitor.VisitPrimitiveExpression(this, data);
- }
-
unsafe static TextLocation AdvanceLocation(TextLocation startLocation, string str)
{
int line = startLocation.Line;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs
index 87315b01f..46fc9c106 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs
@@ -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 ClauseRole = new Role("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(IAstVisitor