Example #1
0
            public void SetName(ContextId context, SymbolId name, object value)
            {
                int id = context.Id;

                EnsureDictionary(id);

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

                _dicts[id][name] = value;
            }
Example #2
0
        /// <summary>
        /// Friend class: LanguageContext
        /// Shouldn't be public since the module contexts are baked into code contexts in the case the module is optimized.
        /// </summary>
        internal ModuleContext SetModuleContext(ContextId languageContextId, ModuleContext moduleContext)
        {
            if (languageContextId.Id >= _moduleContexts.Length)
            {
                Array.Resize(ref _moduleContexts, languageContextId.Id + 1);
            }

            ModuleContext original = Interlocked.CompareExchange <ModuleContext>(ref _moduleContexts[languageContextId.Id],
                                                                                 moduleContext,
                                                                                 null);

            return(original ?? moduleContext);
        }
Example #3
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);
            }
Example #4
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);
            //}
        }
Example #5
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);
            }
        }
Example #6
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);
                }
            }
Example #7
0
 /// <summary>
 /// Friend class: LanguageContext
 /// </summary>
 /// <param name="languageContextId"></param>
 /// <returns></returns>
 internal ModuleContext GetModuleContext(ContextId languageContextId)
 {
     return((languageContextId.Id < _moduleContexts.Length) ? _moduleContexts[languageContextId.Id] : null);
 }