예제 #1
0
        public GraphVizGraph ExportGraph()
        {
            GraphVizGraph graph = new GraphVizGraph();

            foreach (ControlFlowNode node in nodes)
            {
                graph.AddNode(new GraphVizNode(node.BlockIndex)
                {
                    label = node.ToString(), shape = "box"
                });
            }
            foreach (ControlFlowNode node in nodes)
            {
                foreach (ControlFlowEdge edge in node.Outgoing)
                {
                    GraphVizEdge e = new GraphVizEdge(edge.Source.BlockIndex, edge.Target.BlockIndex);
                    switch (edge.Type)
                    {
                    case JumpType.Normal:
                        break;

                    default:
                        e.color = "gray";
                        //e.constraint = false;
                        break;
                    }
                    graph.AddEdge(e);
                }
                if (node.ImmediateDominator != null)
                {
                    graph.AddEdge(new GraphVizEdge(node.ImmediateDominator.BlockIndex, node.BlockIndex)
                    {
                        color = "green", constraint = false
                    });
                }
            }
            return(graph);
        }
예제 #2
0
 public void AddEdge(GraphVizEdge edge)
 {
     edges.Add(edge);
 }