Ejemplo n.º 1
0
        /// <summary>
        /// Sets the name to the specified value for the current context.
        ///
        /// The name is an arbitrary object.
        /// </summary>
        public void SetObjectName(ContextId context, object name, object value, ScopeMemberAttributes attributes)
        {
            int id = context.Id;

            if (id == 0)
            {
                if (_attrs != null)
                {
                    _attrs.CheckWritable(name);
                }

                _dict.AddObjectKey(name, value);
                if (attributes != ScopeMemberAttributes.None)
                {
                    if (_attrs == null)
                    {
                        _attrs = new ScopeAttributeDictionary();
                    }
                    _attrs.Set(name, attributes);
                }
            }
            else
            {
                if (_contextScopes == null)
                {
                    _contextScopes = new ContextSensitiveScope();
                }
                _contextScopes.SetObjectName(context, name, value, attributes);
            }
        }
Ejemplo n.º 2
0
        protected LanguageContext(ScriptDomainManager domainManager)
        {
            ContractUtils.RequiresNotNull(domainManager, "domainManager");

            _domainManager = domainManager;
            _id            = domainManager.GenerateContextId();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the ScopeExtension to the provided value for the given ContextId.
        ///
        /// The extension can only be set once.  The returned value is either the new ScopeExtension
        /// if no value was previously set or the previous value.
        /// </summary>
        public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension)
        {
            ContractUtils.RequiresNotNull(extension, "extension");

            lock (_extensions) {
                if (languageContextId.Id >= _extensions.Length)
                {
                    Array.Resize(ref _extensions, languageContextId.Id + 1);
                }

                return(_extensions[languageContextId.Id] ?? (_extensions[languageContextId.Id] = extension));
            }
        }
Ejemplo n.º 4
0
        public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension)
        {
            ContractUtils.RequiresNotNull(extension, "extension");

            if (languageContextId.Id >= _extensions.Length)
            {
                Array.Resize(ref _extensions, languageContextId.Id + 1);
            }

            ScopeExtension original = Interlocked.CompareExchange(ref _extensions[languageContextId.Id], extension, null);

            return(original ?? extension);
        }
Ejemplo n.º 5
0
            public void SetName(ContextId context, SymbolId name, object value, ScopeMemberAttributes attrs)
            {
                int id = context.Id;

                EnsureDictionary(id);
                EnsureAttrDict(id);

                if (_attrs != null && id < _attrs.Count)
                {
                    _attrs[id].CheckWritable(name);
                }

                _dicts[id][name] = value;
                _attrs[id].Set(name, attrs);
            }
Ejemplo n.º 6
0
        /// <summary>
        /// Sets a name that is only available in the specified context.
        ///
        /// Provides the ScopeMemberAttributes which should be set on the provided object.
        /// </summary>
        /// <exception cref="MemberAccessException">The name has already been published and marked as ReadOnly</exception>
        public void SetName(ContextId context, SymbolId name, object value, ScopeMemberAttributes attributes)
        {
            if (_attrs != null)
            {
                _attrs.CheckWritable(name);
            }

            if (context == ContextId.Empty)
            {
                SetName(name, value);
            }
            else
            {
                if (_contextScopes == null)
                {
                    _contextScopes = new ContextSensitiveScope();
                }
                _contextScopes.SetName(context, name, value, attributes);
            }
        }
Ejemplo n.º 7
0
            public void SetObjectName(ContextId context, object name, object value, ScopeMemberAttributes attrs)
            {
                int id = context.Id;

                EnsureDictionary(id);
                if (attrs != ScopeMemberAttributes.None)
                {
                    EnsureAttrDict(id);
                }

                if (_attrs != null && id < _attrs.Count)
                {
                    _attrs[id].CheckWritable(name);
                }

                _dicts[id].AddObjectKey(name, value);
                if (attrs != ScopeMemberAttributes.None)
                {
                    _attrs[id].Set(name, attrs);
                }
            }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets the ScopeExtension associated with the provided ContextId.
 /// </summary>
 public ScopeExtension GetExtension(ContextId languageContextId)
 {
     return((languageContextId.Id < _extensions.Length) ? _extensions[languageContextId.Id] : null);
 }