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

  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 Delete : UnaryOp
  23.     {
  24.        
  25.         internal Delete(Context context, AST operand) : base(context, operand)
  26.         {
  27.         }
  28.        
  29.         internal override void CheckIfOKToUseInSuperConstructorCall()
  30.         {
  31.             this.context.HandleError(JSError.NotAllowedInSuperConstructorCall);
  32.         }
  33.        
  34.         internal override object Evaluate()
  35.         {
  36.             try {
  37.                 return this.operand.Delete();
  38.             }
  39.             catch (JScriptException) {
  40.                 return true;
  41.                 //This is according to spec, but not backwards compatible with JS5. The latter throws runtime errors.
  42.             }
  43.         }
  44.        
  45.         internal override IReflect InferType(JSField inference_target)
  46.         {
  47.             return Typeob.Boolean;
  48.         }
  49.        
  50.         internal override AST PartiallyEvaluate()
  51.         {
  52.             this.operand = this.operand.PartiallyEvaluate();
  53.             if (this.operand is Binding)
  54.                 ((Binding)this.operand).CheckIfDeletable();
  55.             else if (this.operand is Call)
  56.                 ((Call)this.operand).MakeDeletable();
  57.             else
  58.                 this.operand.context.HandleError(JSError.NotDeletable);
  59.             return this;
  60.         }
  61.        
  62.         internal override void TranslateToIL(ILGenerator il, Type rtype)
  63.         {
  64.             this.operand.TranslateToILDelete(il, rtype);
  65.         }
  66.     }
  67. }

Developer Fusion