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

  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 VoidOp : UnaryOp
  23.     {
  24.        
  25.         internal VoidOp(Context context, AST operand) : base(context, operand)
  26.         {
  27.         }
  28.        
  29.         internal override object Evaluate()
  30.         {
  31.             this.operand.Evaluate();
  32.             return null;
  33.         }
  34.        
  35.         internal override IReflect InferType(JSField inference_target)
  36.         {
  37.             return Typeob.Empty;
  38.         }
  39.        
  40.         internal override AST PartiallyEvaluate()
  41.         {
  42.             return new ConstantWrapper(null, this.context);
  43.         }
  44.        
  45.         internal override void TranslateToIL(ILGenerator il, Type rtype)
  46.         {
  47.             this.operand.TranslateToIL(il, Typeob.Object);
  48.             //force evaluation
  49.             if (rtype != Typeob.Void) {
  50.                 il.Emit(OpCodes.Ldsfld, CompilerGlobals.undefinedField);
  51.                 Convert.Emit(this, il, Typeob.Object, rtype);
  52.             }
  53.             else
  54.                 il.Emit(OpCodes.Pop);
  55.         }
  56.        
  57.     }
  58. }

Developer Fusion