PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/IronPython_2_0/Src/IronPython/Compiler/Ast/BreakStatement.cs

#
C# | 48 lines | 27 code | 7 blank | 14 comment | 3 complexity | 71d04775bf680c0b91a7bc0e248c19ec MD5 | raw file
 1/* ****************************************************************************
 2 *
 3 * Copyright (c) Microsoft Corporation. 
 4 *
 5 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 6 * copy of the license can be found in the License.html file at the root of this distribution. If 
 7 * you cannot locate the  Microsoft Public License, please send an email to 
 8 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 9 * by the terms of the Microsoft Public License.
10 *
11 * You must not remove this notice, or any other, from this software.
12 *
13 *
14 * ***************************************************************************/
15using System; using Microsoft;
16
17
18using AstUtils = Microsoft.Scripting.Ast.Utils;
19using MSAst = Microsoft.Linq.Expressions;
20
21namespace IronPython.Compiler.Ast {
22
23    public class BreakStatement : Statement {
24        public BreakStatement() {
25        }
26
27        internal override MSAst.Expression Transform(AstGenerator ag) {
28            if (ag.InLoop) {
29                return AstUtils.Break(ag.BreakLabel, Span);
30            } else {
31                ag.AddError("'break' outside loop", Span);
32                return null;
33            }
34        }
35
36        public override void Walk(PythonWalker walker) {
37            if (walker.Walk(this)) {
38            }
39            walker.PostWalk(this);
40        }
41
42        internal override bool CanThrow {
43            get {
44                return false;
45            }
46        }
47    }
48}