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

  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.    
  21. /*
  22.     This interface is implemented by all objects taking part in a scope chain.
  23.    
  24.     The first method either returns the contained object of a with scope, or the global scope.
  25.     The second method runs up the scope chain until it reaches a scope that comprises static variables, for example a module scope.
  26.     The third method is used to find local declarations. This is used at compile time for error checking.
  27.    
  28.     The latter two methods are used to search the scope chain for a variable that could not be finally resolved at compile time.
  29.     This happens when a function that contains an eval refers to a variable in outer scope. Since the eval may declare a local
  30.     with the same name, it is not safe to do early binding to the outer scope variable. Rather than search the entire scope
  31.     chain, these functions search only the part preceding the scope known to have such a variable. If they fail to find such an item
  32.     the early bound code is invoked.
  33.    
  34.     There are two big advantages to doing this:
  35.     1) Successful hashtable lookups (of strings) are much more expensive than unsuccessful lookups and should be avoided.
  36.     2) StackFrames avoid allocating hash tables until a search is actually done on them. By avoiding the lookup
  37.       we avoid the allocation and population of the hash table until it is really necessary.
  38.     */   
  39.    
  40.     public interface IActivationObject
  41.     {
  42.         object GetDefaultThisObject();
  43.         GlobalScope GetGlobalScope();
  44.         //Never returns null.
  45.         FieldInfo GetLocalField(string name);
  46.         object GetMemberValue(string name, int lexlevel);
  47.         FieldInfo GetField(string name, int lexLevel);
  48.     }
  49. }

Developer Fusion