PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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 * ***************************************************************************/
15using System; using Microsoft;
16
17
18using System.Diagnostics;
19using Microsoft.Scripting.Utils;
20
21namespace Microsoft.Scripting.Runtime {
22    /// <summary>
23    /// TODO: Rename to LocalScope
24    /// </summary>    
25    public class CodeContext {
26        public const string ContextFieldName = "__global_context";
27
28        // TODO: move to subclasses
29        private readonly Scope _scope;
30
31        // TODO: move to subclasses
32        private readonly LanguageContext _languageContext;
33
34        private readonly CodeContext _parent;
35
36        public CodeContext Parent {
37            get { return _parent; }
38        }
39
40        // TODO: remove
41        public Scope Scope {
42            get {
43                return _scope;
44            }
45        }
46
47        public virtual Scope GlobalScope {
48            get {
49                Debug.Assert(_scope != null, "Global scope not available");
50                return _scope.ModuleScope;
51            }
52        }
53
54        public LanguageContext LanguageContext {
55            get {
56                return _languageContext;
57            }
58        }
59
60        public CodeContext(Scope scope, LanguageContext languageContext)
61            : this(scope, languageContext, null) {
62        }
63
64        public CodeContext(Scope scope, LanguageContext languageContext, CodeContext parent) {
65            Assert.NotNull(languageContext);
66
67            _languageContext = languageContext;
68            _scope = scope;
69            _parent = parent;
70        }
71    }
72}