PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/ShutdownHandlerStatement.cs

#
C# | 52 lines | 26 code | 9 blank | 17 comment | 0 complexity | 2dbfc803876dd55395a753efab395bfa 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;
23
24namespace IronRuby.Compiler.Ast {
25    using Ast = MSA.Expression;
26    using AstUtils = Microsoft.Scripting.Ast.Utils;
27
28    /// <summary>
29    /// Implements END block. This block behaves like Kernel#at_exit with a true block definition. 
30    /// </summary>
31    public partial class ShutdownHandlerStatement : Expression {
32        private readonly BlockDefinition/*!*/ _block;
33
34        public BlockDefinition/*!*/ Block {
35            get { return _block; }
36        }
37
38        public ShutdownHandlerStatement(LexicalScope/*!*/ definedScope, Statements/*!*/ body, SourceSpan location)
39            : base(location) {
40            _block = new BlockDefinition(definedScope, null, body, location);
41        }
42
43        internal override MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) {
44            return Methods.RegisterShutdownHandler.OpCall(_block.Transform(gen));
45        }
46
47        internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
48            return Ast.Block(Transform(gen), AstUtils.Constant(null));
49        }
50    }
51
52}