PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 0ms 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
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. using AstUtils = Microsoft.Scripting.Ast.Utils;
  22. namespace IronRuby.Compiler.Ast {
  23. using Ast = MSA.Expression;
  24. public partial class RedoStatement : JumpStatement {
  25. public RedoStatement(SourceSpan location)
  26. : base(null, location) {
  27. }
  28. // see Ruby Language.doc/Runtime/Control Flow Implementation/Redo
  29. internal override MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) {
  30. // eval:
  31. if (gen.CompilerOptions.IsEval) {
  32. return Methods.EvalRedo.OpCall(gen.CurrentScopeVariable);
  33. }
  34. // loop:
  35. if (gen.CurrentLoop != null) {
  36. return Ast.Block(
  37. Ast.Assign(gen.CurrentLoop.RedoVariable, AstUtils.Constant(true)),
  38. Ast.Continue(gen.CurrentLoop.ContinueLabel),
  39. AstUtils.Empty()
  40. );
  41. }
  42. // block:
  43. if (gen.CurrentBlock != null) {
  44. return Ast.Continue(gen.CurrentBlock.RedoLabel);
  45. }
  46. // method:
  47. return Methods.MethodRedo.OpCall(gen.CurrentScopeVariable);
  48. }
  49. }
  50. }