GetExtension() public method

Gets the ScopeExtension associated with the provided ContextId.
public GetExtension ( ContextId languageContextId ) : Microsoft.Scripting.Runtime.ScopeExtension
languageContextId ContextId
return Microsoft.Scripting.Runtime.ScopeExtension
Example #1
0
        protected static CodeContext GetContextForScope(Scope scope, SourceUnit sourceUnit) {
            CodeContext ctx;
            var ext = scope.GetExtension(sourceUnit.LanguageContext.ContextId) as PythonScopeExtension;
            if (ext == null) {
                ext = sourceUnit.LanguageContext.EnsureScopeExtension(scope) as PythonScopeExtension;
            }

            ctx = ext.ModuleContext.GlobalContext;
            return ctx;
        }
Example #2
0
        // TODO: remove
        public ScopeExtension EnsureScopeExtension(Scope scope)
        {
            ContractUtils.RequiresNotNull(scope, "scope");
            ScopeExtension extension = scope.GetExtension(ContextId);

            if (extension == null)
            {
                extension = CreateScopeExtension(scope);
                if (extension == null)
                {
                    throw Error.MustReturnScopeExtension();
                }
                return(scope.SetExtension(ContextId, extension));
            }

            return(extension);
        }
Example #3
0
 public ScopeExtension GetScopeExtension(Scope scope)
 {
     ContractUtils.RequiresNotNull(scope, "scope");
     return(scope.GetExtension(ContextId));
 }