5
// Mike Krüger <mkrueger@novell.com>
7
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
namespace ICSharpCode.NRefactory.CSharp
32
public class GotoStatement : Statement
34
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
36
public GotoStatement ()
40
public GotoStatement (string label)
45
public CSharpTokenNode GotoToken {
46
get { return GetChildByRole (GotoKeywordRole); }
51
return GetChildByRole (Roles.Identifier).Name;
54
if (string.IsNullOrEmpty(value))
55
SetChildByRole(Roles.Identifier, null);
57
SetChildByRole(Roles.Identifier, Identifier.Create (value));
61
public CSharpTokenNode SemicolonToken {
62
get { return GetChildByRole (Roles.Semicolon); }
65
public override void AcceptVisitor (IAstVisitor visitor)
67
visitor.VisitGotoStatement (this);
70
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
72
return visitor.VisitGotoStatement (this);
75
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
77
return visitor.VisitGotoStatement (this, data);
80
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
82
GotoStatement o = other as GotoStatement;
83
return o != null && MatchString(this.Label, o.Label);
88
/// or "goto case LabelExpression;"
90
public class GotoCaseStatement : Statement
92
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
93
public static readonly TokenRole CaseKeywordRole = new TokenRole ("case");
95
public CSharpTokenNode GotoToken {
96
get { return GetChildByRole (GotoKeywordRole); }
99
public CSharpTokenNode CaseToken {
100
get { return GetChildByRole (CaseKeywordRole); }
104
/// Used for "goto case LabelExpression;"
106
public Expression LabelExpression {
107
get { return GetChildByRole (Roles.Expression); }
108
set { SetChildByRole (Roles.Expression, value); }
111
public CSharpTokenNode SemicolonToken {
112
get { return GetChildByRole (Roles.Semicolon); }
115
public override void AcceptVisitor (IAstVisitor visitor)
117
visitor.VisitGotoCaseStatement (this);
120
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
122
return visitor.VisitGotoCaseStatement (this);
125
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
127
return visitor.VisitGotoCaseStatement (this, data);
130
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
132
GotoCaseStatement o = other as GotoCaseStatement;
133
return o != null && this.LabelExpression.DoMatch(o.LabelExpression, match);
138
/// or "goto default;"
140
public class GotoDefaultStatement : Statement
142
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
143
public static readonly TokenRole DefaultKeywordRole = new TokenRole ("default");
145
public CSharpTokenNode GotoToken {
146
get { return GetChildByRole (GotoKeywordRole); }
149
public CSharpTokenNode DefaultToken {
150
get { return GetChildByRole (DefaultKeywordRole); }
153
public CSharpTokenNode SemicolonToken {
154
get { return GetChildByRole (Roles.Semicolon); }
157
public override void AcceptVisitor (IAstVisitor visitor)
159
visitor.VisitGotoDefaultStatement (this);
162
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
164
return visitor.VisitGotoDefaultStatement (this);
167
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
169
return visitor.VisitGotoDefaultStatement (this, data);
172
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
174
GotoDefaultStatement o = other as GotoDefaultStatement;