Beispiel #1
0
        private static LocalScope GetMinimalOuterScope(LocalScope outerScope)
        {
            while (outerScope != null &&
                   outerScope._symbols == null &&
                   outerScope._sharedScope == null)
            {
                outerScope = outerScope._outerScope;
            }

            return(outerScope);
        }
Beispiel #2
0
        /// <summary>
        /// Makes a copy of this <see cref="LocalScope"/>.
        /// </summary>
        public LocalScope Copy()
        {
            // if we have any non-shared symbols, then move them into shared chain of symbols that
            // can be shared w/o fear of modification (basically copy-on-fear-of-writing).
            if (_symbols != null && _symbols.Count > 0)
            {
                _sharedScope = new LocalScope(_symbols, null, _sharedScope);
                _symbols     = null;
            }

            return(new LocalScope(null, _outerScope, _sharedScope));
        }
Beispiel #3
0
 /// <summary>
 /// Create a new instance of a <see cref="LocalScope"/>
 /// </summary>
 /// <param name="outerScope">An optional outer scope.</param>
 public LocalScope(LocalScope outerScope = null)
     : this(null, outerScope, null)
 {
 }
Beispiel #4
0
 private LocalScope(Dictionary <string, Symbol> symbols, LocalScope outerScope, LocalScope sharedScope)
 {
     _symbols     = symbols;
     _outerScope  = GetMinimalOuterScope(outerScope);
     _sharedScope = sharedScope;
 }