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

  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 Microsoft.JScript.Vsa;
  19.     using System;
  20.     using System.Collections;
  21.     using System.Configuration.Assemblies;
  22.     using System.Globalization;
  23.     using System.Reflection;
  24.     using System.Runtime.Remoting;
  25.    
  26.     public sealed class Globals
  27.     {
  28.         [ThreadStatic()]
  29.         private static TypeReferences _typeRefs;
  30.         static internal TypeReferences TypeRefs {
  31.             get {
  32.                 TypeReferences typeRefs = Globals._typeRefs;
  33.                 if (null == typeRefs)
  34.                     typeRefs = Globals._typeRefs = Runtime.TypeRefs;
  35.                 return typeRefs;
  36.             }
  37.            
  38.             set { Globals._typeRefs = value; }
  39.         }
  40.        
  41.         private Stack callContextStack;
  42.         private Stack scopeStack;
  43.         internal object caller;
  44.         private SimpleHashtable regExpTable;
  45.         internal GlobalObject globalObject;
  46.         internal VsaEngine engine;
  47.        
  48.         //assembly name attributes
  49.         internal bool assemblyDelaySign = false;
  50.         internal CultureInfo assemblyCulture = null;
  51.         internal AssemblyFlags assemblyFlags = AssemblyFlags.EnableJITcompileTracking | AssemblyFlags.DisableJITcompileOptimizer;
  52.         internal AssemblyHashAlgorithm assemblyHashAlgorithm = AssemblyHashAlgorithm.SHA1;
  53.         internal string assemblyKeyFileName = null;
  54.         internal Context assemblyKeyFileNameContext = null;
  55.         internal string assemblyKeyName = null;
  56.         internal Context assemblyKeyNameContext = null;
  57.         internal Version assemblyVersion = null;
  58.         internal AssemblyVersionCompatibility assemblyVersionCompatibility = (AssemblyVersionCompatibility)0;
  59.        
  60.         private static SimpleHashtable BuiltinFunctionTable = null;
  61.         [ContextStatic()]
  62.         public static VsaEngine contextEngine = null;
  63.         //This keeps track of the (single) engine running in the current context
  64.         internal Globals(bool fast, VsaEngine engine)
  65.         {
  66.             this.engine = engine;
  67.             this.callContextStack = null;
  68.             this.scopeStack = null;
  69.             this.caller = DBNull.Value;
  70.             this.regExpTable = null;
  71.             if (fast)
  72.                 this.globalObject = GlobalObject.commonInstance;
  73.             else
  74.                 this.globalObject = new LenientGlobalObject(engine);
  75.         }
  76.        
  77.         static internal BuiltinFunction BuiltinFunctionFor(object obj, MethodInfo meth)
  78.         {
  79.             if (Globals.BuiltinFunctionTable == null)
  80.                 Globals.BuiltinFunctionTable = new SimpleHashtable(64);
  81.             BuiltinFunction result = (BuiltinFunction)Globals.BuiltinFunctionTable[meth];
  82.             if (result != null)
  83.                 return result;
  84.             result = new BuiltinFunction(obj, meth);
  85.             lock (Globals.BuiltinFunctionTable) {
  86.                 Globals.BuiltinFunctionTable[meth] = result;
  87.             }
  88.             return result;
  89.         }
  90.        
  91.         internal Stack CallContextStack {
  92.             get {
  93.                 if (this.callContextStack == null)
  94.                     this.callContextStack = new Stack();
  95.                 return this.callContextStack;
  96.             }
  97.         }
  98.        
  99.         [JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
  100.         public static ArrayObject ConstructArray(params object[] args)
  101.         {
  102.             return (ArrayObject)ArrayConstructor.ob.Construct(args);
  103.         }
  104.        
  105.         public static ArrayObject ConstructArrayLiteral(object[] args)
  106.         {
  107.             return (ArrayObject)ArrayConstructor.ob.ConstructArray(args);
  108.         }
  109.        
  110.         internal SimpleHashtable RegExpTable {
  111.             get {
  112.                 if (this.regExpTable == null)
  113.                     this.regExpTable = new SimpleHashtable(8);
  114.                 return this.regExpTable;
  115.             }
  116.         }
  117.        
  118.         internal Stack ScopeStack {
  119.             get {
  120.                 if (this.scopeStack == null) {
  121.                     this.scopeStack = new Stack();
  122.                     this.scopeStack.Push(this.engine.GetGlobalScope().GetObject());
  123.                     //This is only needed for ASP+ (since no VsaEngine methods get called in that case).
  124.                 }
  125.                 return this.scopeStack;
  126.             }
  127.         }
  128.        
  129.     }
  130.    
  131.     internal enum AssemblyFlags
  132.     {
  133.         PublicKey = 1,
  134.         // The assembly ref holds the full (unhashed) public key.
  135.         CompatibilityMask = 112,
  136.         SideBySideCompatible = 0,
  137.         // The assembly is side by side compatible.
  138.         NonSideBySideAppDomain = 16,
  139.         // The assembly cannot execute with other versions if they are executing in the same application domain.
  140.         NonSideBySideProcess = 32,
  141.         // The assembly cannot execute with other versions if they are executing in the same process.
  142.         NonSideBySideMachine = 48,
  143.         // The assembly cannot execute with other versions if they are executing on the same machine.
  144.         EnableJITcompileTracking = 32768,
  145.         // From "DebuggableAttribute".
  146.         DisableJITcompileOptimizer = 16384
  147.         // From "DebuggableAttribute".
  148.     }
  149. }

Developer Fusion