diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayCreateExpression.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayCreateExpression.cs index 544213829..b3f580894 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayCreateExpression.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayCreateExpression.cs @@ -61,6 +61,4 @@ namespace ICSharpCode.NRefactory.VB.Ast 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/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/EmptyExpression.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/EmptyExpression.cs new file mode 100644 index 000000000..c475a2b51 --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/EmptyExpression.cs @@ -0,0 +1,59 @@ +// Copyright (c) 2011 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. + +using System; + +namespace ICSharpCode.NRefactory.VB.Ast +{ + public class EmptyExpression : Expression + { + AstLocation location; + + public override AstLocation StartLocation { + get { + return location; + } + } + + public override AstLocation EndLocation { + get { + return location; + } + } + + public EmptyExpression() + { + } + + public EmptyExpression(AstLocation location) + { + this.location = location; + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitEmptyExpression(this, data); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + var o = other as EmptyExpression; + return o != null; + } + } +} diff --git a/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs index 2386e7cf3..746e6fdc9 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs @@ -112,6 +112,6 @@ namespace ICSharpCode.NRefactory.VB { S VisitQueryExpression(QueryExpression queryExpression, T data); - + S VisitEmptyExpression(EmptyExpression emptyExpression, T data); } } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj b/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj index 9d611da29..7b97eb263 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj +++ b/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj @@ -54,6 +54,7 @@ + diff --git a/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs index 7c7251397..994eedd85 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs @@ -2404,5 +2404,12 @@ namespace ICSharpCode.NRefactory.VB new OutputVisitor(writer, new VBFormattingOptions()).WritePrimitiveValue(primitiveExpression.Value); return writer.ToString(); } + + public object VisitEmptyExpression(EmptyExpression emptyExpression, object data) + { + StartNode(emptyExpression); + + return EndNode(emptyExpression); + } } } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs index 8bb349070..34f3e8693 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs @@ -594,7 +594,11 @@ namespace ICSharpCode.NRefactory.VB.Visitors Operator = UnaryOperatorType.AddressOf }; break; -// case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Dereference: + case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Dereference: + expr = new InvocationExpression(); + ((InvocationExpression)expr).Target = new IdentifierExpression() { Identifier = "__Dereference" }; + ((InvocationExpression)expr).Arguments.Add((Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data)); + break; default: throw new Exception("Invalid value for UnaryOperatorType"); } @@ -610,8 +614,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors public AstNode VisitEmptyExpression(CSharp.EmptyExpression emptyExpression, object data) { - // TODO : not used in ILSpy currently - throw new NotImplementedException(); + return EndNode(emptyExpression, new EmptyExpression()); } public AstNode VisitQueryExpression(CSharp.QueryExpression queryExpression, object data) @@ -931,6 +934,10 @@ namespace ICSharpCode.NRefactory.VB.Visitors stmt.Body = (BlockStatement)fixedStatement.EmbeddedStatement.AcceptVisitor(this, data); + foreach (var ident in stmt.Body.Descendants.OfType()) { + ident.ReplaceWith(expr => ((Expression)expr).Invoke("AddrOfPinnedObject")); + } + return EndNode(fixedStatement, stmt); }