PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms 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
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  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. #if !CLR2
  16. using MSA = System.Linq.Expressions;
  17. #else
  18. using MSA = Microsoft.Scripting.Ast;
  19. #endif
  20. using Microsoft.Scripting;
  21. namespace IronRuby.Compiler.Ast {
  22. using Ast = MSA.Expression;
  23. using AstUtils = Microsoft.Scripting.Ast.Utils;
  24. /// <summary>
  25. /// Implements END block. This block behaves like Kernel#at_exit with a true block definition.
  26. /// </summary>
  27. public partial class ShutdownHandlerStatement : Expression {
  28. private readonly BlockDefinition/*!*/ _block;
  29. public BlockDefinition/*!*/ Block {
  30. get { return _block; }
  31. }
  32. public ShutdownHandlerStatement(LexicalScope/*!*/ definedScope, Statements/*!*/ body, SourceSpan location)
  33. : base(location) {
  34. _block = new BlockDefinition(definedScope, null, body, location);
  35. }
  36. internal override MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) {
  37. return Methods.RegisterShutdownHandler.OpCall(_block.Transform(gen));
  38. }
  39. internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
  40. return Ast.Block(Transform(gen), AstUtils.Constant(null));
  41. }
  42. }
  43. }