예제 #1
0
파일: Graph.cs 프로젝트: mosamy/vulcan
        private void OnRemoveEdge(GraphEdge <T> edge)
        {
            edge.Sink.IncomingEdges.Remove(edge);
            edge.Source.OutgoingEdges.Remove(edge);

            if (edge.Sink.IsRootNode)
            {
                RootNodes.Add(edge.Sink);
            }

            if (edge.Source.IsLeafNode)
            {
                LeafNodes.Add(edge.Source);
            }
        }
예제 #2
0
        private void OnSourceGraphEdgeAdded(GraphEdge <T> newGraphEdge)
        {
            GraphNode <T> source = newGraphEdge.Source;
            GraphNode <T> sink   = newGraphEdge.Sink;

            if (sink.IncomingEdges.Count == 1 && source.OutgoingEdges.Count == 1)
            {
                MergeBasicBlock(_blockMapping[source], _blockMapping[sink]);
            }
            else if (sink.IncomingEdges.Count == 1 && source.OutgoingEdges.Count == 2)
            {
                var otherSourceEdge = source.OutgoingEdges[0] == newGraphEdge ? source.OutgoingEdges[1] : source.OutgoingEdges[0];
                if (otherSourceEdge.Sink.IncomingEdges.Count == 1)
                {
                    SplitBasicBlock(_blockMapping[otherSourceEdge.Source], otherSourceEdge.Sink.Item);
                }

                if (FindEdge(_blockMapping[source], _blockMapping[sink]) == null)
                {
                    OnAddEdge(_blockMapping[source], _blockMapping[sink], newGraphEdge);
                }
            }
            else if (sink.IncomingEdges.Count == 2)
            {
                var otherEdge = sink.IncomingEdges[0] == newGraphEdge ? sink.IncomingEdges[1] : sink.IncomingEdges[0];
                if (otherEdge.Source.OutgoingEdges.Count == 1)
                {
                    SplitBasicBlock(_blockMapping[otherEdge.Source], sink.Item);
                }
            }
            else
            {
                if (FindEdge(_blockMapping[source], _blockMapping[sink]) == null)
                {
                    OnAddEdge(_blockMapping[source], _blockMapping[sink], newGraphEdge);
                }
            }
        }
예제 #3
0
        private void OnSourceGraphEdgeRemoved(GraphEdge <T> oldGraphEdge)
        {
            GraphNode <T> source = oldGraphEdge.Source;
            GraphNode <T> sink   = oldGraphEdge.Sink;

            if (sink.IncomingEdges.Count == 0 && source.OutgoingEdges.Count == 0)
            {
                SplitBasicBlock(_blockMapping[source], sink.Item);
            }
            else if (sink.IncomingEdges.Count == 0 && source.OutgoingEdges.Count == 1 && source.OutgoingEdges[0].Sink.IncomingEdges.Count == 1)
            {
                MergeBasicBlock(_blockMapping[source], _blockMapping[source.OutgoingEdges[0].Sink]);
            }
            else if (sink.IncomingEdges.Count == 1 && !sink.IsLeader)
            {
                MergeBasicBlock(_blockMapping[sink.IncomingEdges[0].Source], _blockMapping[sink]);
            }

            if (SourceGraph.FindEdge(source.Item, sink.Item) == null)
            {
                OnRemoveEdge(FindEdge(_blockMapping[source], _blockMapping[sink]));
            }
        }
예제 #4
0
파일: Graph.cs 프로젝트: mosamy/vulcan
 public void RelocateEdge(GraphEdge <T> edge, GraphNode <T> newSourceNode, GraphNode <T> newSinkNode)
 {
     GraphManager.GraphEdgeRelocator.RelocateEdge(this, edge, newSourceNode, newSinkNode);
 }
예제 #5
0
파일: Graph.cs 프로젝트: mosamy/vulcan
 public bool RemoveEdge(GraphEdge <T> edge)
 {
     return(GraphManager.GraphEdgeRemover.RemoveEdge(this, edge));
 }
예제 #6
0
파일: Graph.cs 프로젝트: mosamy/vulcan
 public GraphEdge <T> AddEdge(GraphEdge <T> edge)
 {
     GraphManager.GraphEdgeBuilder.AddEdge(this, edge);
     return(edge);
 }
예제 #7
0
 private void OnRemoveEdge(GraphEdge <BasicBlock <T> > edge)
 {
     RemoveEdge(edge);
 }
예제 #8
0
 private void OnAddEdge(GraphNode <BasicBlock <T> > sourceNode, GraphNode <BasicBlock <T> > sinkNode, GraphEdge <T> dataProvider)
 {
     AddEdge(sourceNode, sinkNode, null, dataProvider.SourceData, dataProvider.SinkData);
 }
예제 #9
0
 private void OnAddEdge(BasicBlock <T> source, BasicBlock <T> sink, GraphEdge <T> dataProvider)
 {
     AddEdge(source, sink, null, dataProvider.SourceData, dataProvider.SinkData);
 }