Пример #1
0
    /// <summary>
    /// 更新语法树
    /// </summary>
    /// <param name="oldCode">旧代码</param>
    /// <param name="newCode">新代码</param>
    /// <param name="sets">新的引用</param>
    public override void Update(string oldCode, string newCode, HashSet <string> sets = default)
    {
        //先移除
        if (TreeCache.ContainsKey(oldCode))
        {
            while (!TreeCache.TryRemove(oldCode, out _))
            {
            }
            ;
        }
        if (sets == default)
        {
            if (ReferenceCache.ContainsKey(oldCode))
            {
                sets = ReferenceCache[oldCode];
                while (!ReferenceCache.TryRemove(oldCode, out _))
                {
                }
                ;
            }
        }

        //再添加
        AddTreeToCache(newCode);
        ReferenceCache[newCode] = sets;
    }
Пример #2
0
        public static Node FindTreeClosestToBlackHeight(List <int> elements, int blackHeight)
        {
            _elements = elements;
            _elements.Sort();
            _cache = new TreeCache(elements.Count);

            var tree = _cache.GetTreeClosestToBlackHeight(elements.Count, blackHeight);

            tree.FillWithValues(elements);
            return(tree);
        }
Пример #3
0
    /// <summary>
    /// 更新语法树
    /// </summary>
    /// <param name="oldCode">旧代码</param>
    /// <param name="newCode">新代码</param>
    /// <param name="usings">新的引用</param>
    public override void Update(string oldCode, string newCode, HashSet <string> usings = default)
    {
        //先移除
        TreeCache.Remove(oldCode);
        if (usings == default)
        {
            if (ReferenceCache.ContainsKey(oldCode))
            {
                usings = ReferenceCache[oldCode];
                ReferenceCache.Remove(oldCode);
            }
        }

        //再添加
        AddTreeToCache(newCode);
        ReferenceCache[newCode] = usings;
    }
Пример #4
0
 public CompilationException Update(string old, string @new, HashSet <string> sets = default)
 {
     if (TreeCache.ContainsKey(old))
     {
         while (!TreeCache.TryRemove(old, out _))
         {
         }
         ;
     }
     if (sets == default)
     {
         if (UsingCache.ContainsKey(old))
         {
             sets = UsingCache[old];
             while (!UsingCache.TryRemove(old, out _))
             {
             }
             ;
         }
     }
     return(Add(@new, sets));
 }
Пример #5
0
    public override void Update(string old, string @new, HashSet <string> sets = default)
    {
        if (TreeCache.ContainsKey(old))
        {
            while (!TreeCache.TryRemove(old, out _))
            {
            }
            ;
        }
        if (sets == default)
        {
            if (ReferenceCache.ContainsKey(old))
            {
                sets = ReferenceCache[old];
                while (!ReferenceCache.TryRemove(old, out _))
                {
                }
                ;
            }
        }

        AddTreeToCache(@new);
        ReferenceCache[@new] = sets;
    }
Пример #6
0
        public virtual void Update(string old, string @new, HashSet <string> sets = default)
        {
            if (TreeCache.ContainsKey(old))
            {
                while (!TreeCache.TryRemove(old, out _))
                {
                }
                ;
            }
            if (sets == default)
            {
                if (UsingCache.ContainsKey(old))
                {
                    sets = UsingCache[old];
                    while (!UsingCache.TryRemove(old, out _))
                    {
                    }
                    ;
                }
            }

            AddTreeToCache(@new);
            UsingCache[@new] = sets;
        }
Пример #7
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TreeCache obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Пример #8
0
 /// <summary>
 /// Constructor. </summary>
 /// <param name="builder"> the tree builder </param>
 /// <param name="cache"> the tree cache (may be <code>null</code>) </param>
 public TreeStore(TreeBuilder builder, TreeCache cache) : base()
 {
     this.builder = builder;
     this.cache   = cache;
 }