示例#1
0
        public string GetAssemblyName(CondensedVertex vassem)
        {
            int    count    = 0;
            string baseName = NameHint;

            if (vassem.NameSpaces.Count == 1)
            {
                baseName = TypeVertex.GetNamespace(vassem);
            }

            nameHintCountMap.TryGetValue(baseName, out count);
            nameHintCountMap[baseName] = count + 1;

            return(String.Format("{0}.{1}", baseName, count));
        }
        public void Condense()
        {
            NameSpaces.Clear();
            foreach (TypeReference tref in ContainedTypes)
            {
                string nmspace = TypeVertex.GetNamespace(tref);

                if (this.NameSpaces.ContainsKey(nmspace))
                {
                    this.NameSpaces[nmspace]++;
                }
                else
                {
                    this.NameSpaces[nmspace] = 1;
                }
            }
        }
        internal void Condense(IVertexCollection iVertexCollection)
        {
            foreach (TypeVertex v in iVertexCollection)
            {
                if (!this.ContainedTypes.Contains(v.TypeRef))
                {
                    this.ContainedTypes.Add(v.TypeRef);
                }
                string nmspace = TypeVertex.GetNamespace(v.TypeRef);

                if (this.NameSpaces.ContainsKey(nmspace))
                {
                    this.NameSpaces[nmspace]++;
                }
                else
                {
                    this.NameSpaces[nmspace] = 1;
                }
            }
        }
示例#4
0
        void dfs_DiscoverVertex(object sender, VertexEventArgs e)
        {
            CondensedVertex v = (CondensedVertex)e.Vertex;

            Trace.WriteLine("S: " + v.Name);
            Trace.Indent();
            PendingEdges.Push(new List <CondensedVertex>());

            Debug.Assert(!destcg.ContainsVertex(v));

            CondensedVertex nv;

            if (v.NameSpaces.Count > 1)             // scc with mult NS
            {
                destcg.AddVertex(v);
                VertexReassignmentMap[v] = v;
                return;
            }
            string trefNamespace = TypeVertex.GetNamespace(v);

            if (!NamespaceVertexMap.ContainsKey(trefNamespace))
            {
                nv = (CondensedVertex)destcg.AddVertex();
                nv.NameSpaces[trefNamespace]      = 0;
                NamespaceVertexMap[trefNamespace] = new List <CondensedVertex>();
                NamespaceVertexMap[trefNamespace].Add(nv);
            }
            else
            {
                nv = NamespaceVertexMap[trefNamespace][0];
            }

            nv.NameSpaces[trefNamespace]++;
            foreach (TypeReference tref in v.ContainedTypes)
            {
                nv.ContainedTypes.Add(tref);
            }
            VertexReassignmentMap[v] = nv;
            return;
        }
示例#5
0
        public void CompactNS(bool agressive)
        {
            List <CondensedVertex> allvertex = new List <CondensedVertex>();

            foreach (CondensedVertex v in this.Vertices)
            {
                allvertex.Add(v);
            }

            foreach (CondensedVertex v in allvertex)
            {
                if (v.NameSpaces.Count > 1 || v.ImutableExternalType)
                {
                    continue;
                    //throw new NotImplementedException();
                }

                int numVertex = this.VerticesCount;
                Debug.Assert(numVertex == SCCCount);

                string ns = TypeVertex.GetNamespace(v);

                List <CondensedVertex> candidateDestVertexs;
                if (!NamespaceAssignmentMap.TryGetValue(ns, out candidateDestVertexs))
                {
                    candidateDestVertexs       = new List <CondensedVertex>();
                    NamespaceAssignmentMap[ns] = candidateDestVertexs;
                }

                bool vertexReasigned = false;

                foreach (CondensedVertex destV in candidateDestVertexs)
                {
                    vertexReasigned = TryMergeVertex(v, destV, ref numVertex);
                    if (vertexReasigned)
                    {
                        break;
                    }
                }

                if (!vertexReasigned && agressive)
                {
                    foreach (List <CondensedVertex> listC in NamespaceAssignmentMap.Values)
                    {
                        if (listC != candidateDestVertexs && !vertexReasigned)
                        {
                            foreach (CondensedVertex destV in listC)
                            {
                                vertexReasigned = TryMergeVertex(v, destV, ref numVertex);
                                if (vertexReasigned)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                if (!vertexReasigned)
                {
                    numVertex++;
                    CondensedVertex destV = this.AddVertex() as CondensedVertex;
                    NamespaceAssignmentMap[ns].Add(destV);
                    vertexReasigned = TryMergeVertex(v, destV, ref numVertex);
                    Debug.Assert(vertexReasigned);
                }
            }
            Debug.Assert(this.VerticesCount == SCCCount);
            Debug.WriteLine(VerticesCount.ToString());
        }