/IronPython_2_0/Src/Microsoft.Scripting/Runtime/CodeContext.cs

# · C# · 72 lines · 39 code · 13 blank · 20 comment · 1 complexity · b28d7d43f9a230e321c57669ac6f4aca MD5 · raw file

  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Microsoft Public License. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Microsoft Public License, please send an email to
  8. * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Microsoft Public License.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System; using Microsoft;
  16. using System.Diagnostics;
  17. using Microsoft.Scripting.Utils;
  18. namespace Microsoft.Scripting.Runtime {
  19. /// <summary>
  20. /// TODO: Rename to LocalScope
  21. /// </summary>
  22. public class CodeContext {
  23. public const string ContextFieldName = "__global_context";
  24. // TODO: move to subclasses
  25. private readonly Scope _scope;
  26. // TODO: move to subclasses
  27. private readonly LanguageContext _languageContext;
  28. private readonly CodeContext _parent;
  29. public CodeContext Parent {
  30. get { return _parent; }
  31. }
  32. // TODO: remove
  33. public Scope Scope {
  34. get {
  35. return _scope;
  36. }
  37. }
  38. public virtual Scope GlobalScope {
  39. get {
  40. Debug.Assert(_scope != null, "Global scope not available");
  41. return _scope.ModuleScope;
  42. }
  43. }
  44. public LanguageContext LanguageContext {
  45. get {
  46. return _languageContext;
  47. }
  48. }
  49. public CodeContext(Scope scope, LanguageContext languageContext)
  50. : this(scope, languageContext, null) {
  51. }
  52. public CodeContext(Scope scope, LanguageContext languageContext, CodeContext parent) {
  53. Assert.NotNull(languageContext);
  54. _languageContext = languageContext;
  55. _scope = scope;
  56. _parent = parent;
  57. }
  58. }
  59. }