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

/IronPython_Main/Languages/Ruby/Ruby/Compiler/Ast/JumpStatements/RedoStatement.cs

#
C# | 59 lines | 31 code | 9 blank | 19 comment | 5 complexity | 3acfba625f003c62c8c2e5360e57cdd9 MD5 | raw file
 1/* ****************************************************************************
 2 *
 3 * Copyright (c) Microsoft Corporation. 
 4 *
 5 * This source code is subject to terms and conditions of the Apache License, Version 2.0. 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  Apache License, Version 2.0, please send an email to 
 8 * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 9 * by the terms of the Apache License, Version 2.0.
10 *
11 * You must not remove this notice, or any other, from this software.
12 *
13 *
14 * ***************************************************************************/
15
16#if !CLR2
17using MSA = System.Linq.Expressions;
18#else
19using MSA = Microsoft.Scripting.Ast;
20#endif
21
22using Microsoft.Scripting;
23using AstUtils = Microsoft.Scripting.Ast.Utils;
24
25namespace IronRuby.Compiler.Ast {
26    using Ast = MSA.Expression;
27    
28    public partial class RedoStatement : JumpStatement {
29        public RedoStatement(SourceSpan location)
30            : base(null, location) {
31        }
32
33        // see Ruby Language.doc/Runtime/Control Flow Implementation/Redo
34        internal override MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) {
35
36            // eval:
37            if (gen.CompilerOptions.IsEval) {
38                return Methods.EvalRedo.OpCall(gen.CurrentScopeVariable);
39            }
40
41            // loop:
42            if (gen.CurrentLoop != null) {
43                return Ast.Block(
44                    Ast.Assign(gen.CurrentLoop.RedoVariable, AstUtils.Constant(true)),
45                    Ast.Continue(gen.CurrentLoop.ContinueLabel),
46                    AstUtils.Empty()
47                );
48            }
49
50            // block:
51            if (gen.CurrentBlock != null) {
52                return Ast.Continue(gen.CurrentBlock.RedoLabel);
53            }
54
55            // method:
56            return Methods.MethodRedo.OpCall(gen.CurrentScopeVariable);
57        }
58    }
59}