Browse Source

add ContinueStatement

newNRvisualizers
Siegfried Pammer 14 years ago
parent
commit
eab1ac6611
  1. 50
      ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs
  2. 2
      ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs
  3. 1
      ICSharpCode.NRefactory.VB/IAstVisitor.cs
  4. 1
      ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj
  5. 23
      ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs
  6. 21
      ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

50
ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.IO;
namespace ICSharpCode.NRefactory.VB.Ast
{
/// <summary>
/// Continue ( Do | For | While )
/// </summary>
public class ContinueStatement : Statement
{
public static readonly Role<VBTokenNode> ContinueKindTokenRole = new Role<VBTokenNode>("ContinueKindToken");
public ContinueKind ContinueKind { get; set; }
public VBTokenNode ContinueToken {
get { return GetChildByRole (Roles.Keyword); }
}
public VBTokenNode ContinueKindToken {
get { return GetChildByRole (ContinueKindTokenRole); }
}
public ContinueStatement(ContinueKind kind)
{
this.ContinueKind = kind;
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitContinueStatement(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ContinueStatement o = other as ContinueStatement;
return o != null && this.ContinueKind == o.ContinueKind;
}
}
public enum ContinueKind
{
None,
Do,
For,
While
}
}

2
ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs

@ -11,7 +11,7 @@ namespace ICSharpCode.NRefactory.VB.Ast @@ -11,7 +11,7 @@ namespace ICSharpCode.NRefactory.VB.Ast
/// </summary>
public class ExitStatement : Statement
{
public static readonly Role<VBTokenNode> ExitKindTokenRole = new Role<VBTokenNode>("ExitKindTokenRole");
public static readonly Role<VBTokenNode> ExitKindTokenRole = new Role<VBTokenNode>("ExitKindToken");
public ExitKind ExitKind { get; set; }

1
ICSharpCode.NRefactory.VB/IAstVisitor.cs

@ -85,6 +85,7 @@ namespace ICSharpCode.NRefactory.VB { @@ -85,6 +85,7 @@ namespace ICSharpCode.NRefactory.VB {
S VisitForStatement(ForStatement forStatement, T data);
S VisitForEachStatement(ForEachStatement forEachStatement, T data);
S VisitExitStatement(ExitStatement exitStatement, T data);
S VisitContinueStatement(ContinueStatement continueStatement, T data);
S VisitSelectStatement(SelectStatement selectStatement, T data);
S VisitYieldStatement(YieldStatement yieldStatement, T data);
S VisitVariableInitializer(VariableInitializer variableInitializer, T data);

1
ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj

@ -95,6 +95,7 @@ @@ -95,6 +95,7 @@
<Compile Include="Ast\Identifier.cs" />
<Compile Include="Ast\INullable.cs" />
<Compile Include="Ast\Statements\BlockStatement.cs" />
<Compile Include="Ast\Statements\ContinueStatement.cs" />
<Compile Include="Ast\Statements\DoLoopStatement.cs" />
<Compile Include="Ast\Statements\ExitStatement.cs" />
<Compile Include="Ast\Statements\ExpressionStatement.cs" />

23
ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs

@ -2319,5 +2319,28 @@ namespace ICSharpCode.NRefactory.VB @@ -2319,5 +2319,28 @@ namespace ICSharpCode.NRefactory.VB
return EndNode(queryExpression);
}
public object VisitContinueStatement(ContinueStatement continueStatement, object data)
{
StartNode(continueStatement);
WriteKeyword("Continue");
switch (continueStatement.ContinueKind) {
case ContinueKind.Do:
WriteKeyword("Do");
break;
case ContinueKind.For:
WriteKeyword("For");
break;
case ContinueKind.While:
WriteKeyword("While");
break;
default:
throw new Exception("Invalid value for ContinueKind");
}
return EndNode(continueStatement);
}
}
}

21
ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

@ -803,13 +803,30 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -803,13 +803,30 @@ namespace ICSharpCode.NRefactory.VB.Visitors
public AstNode VisitCheckedStatement(CSharp.CheckedStatement checkedStatement, object data)
{
// overflow/underflow checks are default on in VB
// overflow/underflow checks are on by default in VB
throw new NotImplementedException();
}
public AstNode VisitContinueStatement(CSharp.ContinueStatement continueStatement, object data)
{
throw new NotImplementedException();
var @continue = new ContinueStatement(ContinueKind.None);
foreach (var stmt in continueStatement.Ancestors) {
if (stmt is CSharp.DoWhileStatement) {
@continue.ContinueKind = ContinueKind.Do;
break;
}
if (stmt is CSharp.ForStatement || stmt is CSharp.ForeachStatement) {
@continue.ContinueKind = ContinueKind.For;
break;
}
if (stmt is CSharp.WhileStatement) {
@continue.ContinueKind = ContinueKind.While;
break;
}
}
return EndNode(continueStatement, @continue);
}
public AstNode VisitDoWhileStatement(CSharp.DoWhileStatement doWhileStatement, object data)

Loading…
Cancel
Save