Browse Source

WIP

ast-source-generator
Siegfried Pammer 3 months ago
parent
commit
0541e53b1d
  1. 4
      ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs
  2. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs
  3. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs
  4. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs
  5. 9
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs
  6. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs
  7. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs
  8. 11
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs
  9. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs

4
ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs

@ -244,6 +244,10 @@ internal class DecompilerSyntaxTreeGenerator : IIncrementalGenerator @@ -244,6 +244,10 @@ internal class DecompilerSyntaxTreeGenerator : IIncrementalGenerator
{
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}");

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

@ -58,12 +58,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -58,12 +58,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(castToType, Roles.Type);
AddChild(expression, Roles.Expression);
}
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);
}
}
}

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

@ -59,11 +59,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -59,11 +59,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
AddChild(expression, Roles.Expression);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CheckedExpression o = other as CheckedExpression;
return o != null && this.Expression.DoMatch(o.Expression, match);
}
}
}

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

@ -70,11 +70,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -70,11 +70,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
AddChild(trueExpression, TrueRole);
AddChild(falseExpression, FalseRole);
}
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);
}
}
}

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

@ -16,8 +16,6 @@ @@ -16,8 +16,6 @@
// 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>
@ -35,12 +33,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -35,12 +33,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.VariableDesignationRole); }
set { SetChildByRole(Roles.VariableDesignationRole, value); }
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return other is DeclarationExpression o
&& Type.DoMatch(o.Type, match)
&& Designation.DoMatch(o.Designation, match);
}
}
}

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

@ -60,12 +60,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -60,12 +60,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
AddChild(type, Roles.Type);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DefaultValueExpression o = other as DefaultValueExpression;
return o != null && this.Type.DoMatch(o.Type, match);
}
}
}

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

@ -78,11 +78,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -78,11 +78,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.FieldDirection = direction;
AddChild(expression, Roles.Expression);
}
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);
}
}
}

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

@ -42,11 +42,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -42,11 +42,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public string Error {
get;
private set;
}
public ErrorExpression()
{
}
@ -55,12 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -55,12 +50,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
AddChild(new Comment(error, CommentType.MultiLine), Roles.Comment);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as ErrorExpression;
return o != null;
}
}
}

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

@ -64,11 +64,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -64,11 +64,5 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole(Roles.TypeArgument); }
}
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);
}
}
}

Loading…
Cancel
Save