Browse Source

Add OutVarDeclarationExpression

pull/844/head
Siegfried Pammer 8 years ago
parent
commit
a393648671
  1. 13
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs
  2. 15
      ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs
  3. 73
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs
  4. 3
      ICSharpCode.Decompiler/CSharp/Syntax/IAstVisitor.cs
  5. 7
      ICSharpCode.Decompiler/CSharp/Syntax/ObservableAstVisitor.cs
  6. 1
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

13
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -766,6 +766,19 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -766,6 +766,19 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
EndNode(directionExpression);
}
public virtual void VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression)
{
StartNode(outVarDeclarationExpression);
WriteKeyword(OutVarDeclarationExpression.OutKeywordRole);
Space();
outVarDeclarationExpression.Type.AcceptVisitor(this);
Space();
outVarDeclarationExpression.Expression.AcceptVisitor(this);
EndNode(outVarDeclarationExpression);
}
public virtual void VisitIdentifierExpression(IdentifierExpression identifierExpression)
{
StartNode(identifierExpression);

15
ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs

@ -471,6 +471,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -471,6 +471,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
VisitChildren (objectCreateExpression);
}
public virtual void VisitOutVarDeclarationExpression (OutVarDeclarationExpression outVarDeclarationExpression)
{
VisitChildren (outVarDeclarationExpression);
}
public virtual void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
{
VisitChildren (anonymousTypeCreateExpression);
@ -1078,6 +1083,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1078,6 +1083,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return VisitChildren (objectCreateExpression);
}
public virtual T VisitOutVarDeclarationExpression (OutVarDeclarationExpression outVarDeclarationExpression)
{
return VisitChildren(outVarDeclarationExpression);
}
public virtual T VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
{
return VisitChildren (anonymousTypeCreateExpression);
@ -1685,6 +1695,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1685,6 +1695,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return VisitChildren (objectCreateExpression, data);
}
public virtual S VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression, T data)
{
return VisitChildren (outVarDeclarationExpression, data);
}
public virtual S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data)
{
return VisitChildren (anonymousTypeCreateExpression, data);

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

@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
// 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
{
/// <summary>
/// out type expression
/// </summary>
public class OutVarDeclarationExpression : Expression
{
public readonly static TokenRole OutKeywordRole = DirectionExpression.OutKeywordRole;
public CSharpTokenNode OutKeywordToken {
get { return GetChildByRole(OutKeywordRole); }
}
public AstType Type {
get { return GetChildByRole(Roles.Type); }
set { SetChildByRole(Roles.Type, value); }
}
public Expression Expression {
get { return GetChildByRole(Roles.Expression); }
set { SetChildByRole(Roles.Expression, value); }
}
public OutVarDeclarationExpression()
{
}
public OutVarDeclarationExpression(AstType type, string name)
{
this.Type = type;
this.Expression = new IdentifierExpression(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;
return o != null && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match);
}
}
}

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

@ -47,6 +47,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -47,6 +47,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
void VisitNamedExpression(NamedExpression namedExpression);
void VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
void VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
void VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression);
void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
void VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
@ -179,6 +180,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -179,6 +180,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
S VisitNamedExpression(NamedExpression namedExpression);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
S VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
@ -311,6 +313,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -311,6 +313,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
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 VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data);

7
ICSharpCode.Decompiler/CSharp/Syntax/ObservableAstVisitor.cs

@ -640,6 +640,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -640,6 +640,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Visit(EnterObjectCreateExpression, LeaveObjectCreateExpression, objectCreateExpression);
}
public event Action<OutVarDeclarationExpression> EnterOutVarDeclarationExpression, LeaveOutVarDeclarationExpression;
void IAstVisitor.VisitOutVarDeclarationExpression(OutVarDeclarationExpression outVarDeclarationExpression)
{
Visit(EnterOutVarDeclarationExpression, LeaveOutVarDeclarationExpression, outVarDeclarationExpression);
}
public event Action<AnonymousTypeCreateExpression> EnterAnonymousTypeCreateExpression, LeaveAnonymousTypeCreateExpression;
void IAstVisitor.VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)

1
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
<Compile Include="CSharp\Syntax\Expressions\NamedExpression.cs" />
<Compile Include="CSharp\Syntax\Expressions\NullReferenceExpression.cs" />
<Compile Include="CSharp\Syntax\Expressions\ObjectCreateExpression.cs" />
<Compile Include="CSharp\Syntax\Expressions\OutVarDeclarationExpression.cs" />
<Compile Include="CSharp\Syntax\Expressions\ParenthesizedExpression.cs" />
<Compile Include="CSharp\Syntax\Expressions\PointerReferenceExpression.cs" />
<Compile Include="CSharp\Syntax\Expressions\PrimitiveExpression.cs" />

Loading…
Cancel
Save