The Labs \ Source Viewer \ SSCLI \ Microsoft.JScript \ Continue

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. namespace Microsoft.JScript
  16. {
  17.    
  18.     using System;
  19.     using System.Reflection;
  20.     using System.Reflection.Emit;
  21.    
  22.     internal sealed class Continue : AST
  23.     {
  24.         private Completion completion;
  25.         private bool leavesFinally;
  26.        
  27.         internal Continue(Context context, int count, bool leavesFinally) : base(context)
  28.         {
  29.             this.completion = new Completion();
  30.             this.completion.Continue = count;
  31.             this.leavesFinally = leavesFinally;
  32.         }
  33.        
  34.         internal override object Evaluate()
  35.         {
  36.             return this.completion;
  37.         }
  38.        
  39.         internal override AST PartiallyEvaluate()
  40.         {
  41.             if (this.leavesFinally)
  42.                 this.context.HandleError(JSError.BadWayToLeaveFinally);
  43.             return this;
  44.         }
  45.        
  46.         internal override void TranslateToIL(ILGenerator il, Type rtype)
  47.         {
  48.             Label continue_label = (Label)compilerGlobals.ContinueLabelStack.Peek(this.completion.Continue - 1);
  49.             this.context.EmitLineInfo(il);
  50.             if (this.leavesFinally) {
  51.                 ConstantWrapper.TranslateToILInt(il, compilerGlobals.ContinueLabelStack.Size() - this.completion.Continue);
  52.                 il.Emit(OpCodes.Newobj, CompilerGlobals.continueOutOfFinallyConstructor);
  53.                 il.Emit(OpCodes.Throw);
  54.             }
  55.             else if (compilerGlobals.InsideProtectedRegion)
  56.                 il.Emit(OpCodes.Leave, continue_label);
  57.             else
  58.                 il.Emit(OpCodes.Br, continue_label);
  59.             //Do not leave anything on the stack, even if rtype != Void.class
  60.         }
  61.        
  62.         internal override void TranslateToILInitializer(ILGenerator il)
  63.         {
  64.         }
  65.     }
  66. }

Developer Fusion