コード例 #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);
 }