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

  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 StaticInitializer : AST
  23.     {
  24.         private FunctionObject func;
  25.         private Completion completion;
  26.        
  27.         internal StaticInitializer(Context context, Block body, FunctionScope own_scope) : base(context)
  28.         {
  29.             this.func = new FunctionObject(null, new ParameterDeclaration[0], null, body, own_scope, Globals.ScopeStack.Peek(), context, MethodAttributes.Private | MethodAttributes.Static);
  30.             this.func.isMethod = true;
  31.             this.func.hasArgumentsObject = false;
  32.             this.completion = new Completion();
  33.         }
  34.        
  35.         internal override object Evaluate()
  36.         {
  37.             this.func.Call(new object[0], ((IActivationObject)Globals.ScopeStack.Peek()).GetGlobalScope());
  38.             return this.completion;
  39.         }
  40.        
  41.         internal override AST PartiallyEvaluate()
  42.         {
  43.             this.func.PartiallyEvaluate();
  44.             return this;
  45.         }
  46.        
  47.         internal override void TranslateToIL(ILGenerator il, Type rtype)
  48.         {
  49.             Debug.Assert(rtype == Typeob.Void);
  50.             this.func.TranslateBodyToIL(il, this.compilerGlobals);
  51.         }
  52.        
  53.         internal override void TranslateToILInitializer(ILGenerator il)
  54.         {
  55.             throw new JScriptException(JSError.InternalError, this.context);
  56.         }
  57.     }
  58. }

Developer Fusion