comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java @ 22355:ef3c3b62e0fc

GraphPrintVisitor: begin a graph if visit is called without beginGraph
author Andreas Woess <andreas.woess@oracle.com>
date Tue, 10 Nov 2015 20:13:14 +0100
parents 4f3eda22dbe9
children a360c82ba357
comparison
equal deleted inserted replaced
22354:0ad8cb1608be 22355:ef3c3b62e0fc
57 */ 57 */
58 public class GraphPrintVisitor implements Closeable { 58 public class GraphPrintVisitor implements Closeable {
59 59
60 public static final String GraphVisualizerAddress = "127.0.0.1"; 60 public static final String GraphVisualizerAddress = "127.0.0.1";
61 public static final int GraphVisualizerPort = 4444; 61 public static final int GraphVisualizerPort = 4444;
62 private static final String DEFAULT_GRAPH_NAME = "truffle tree";
62 63
63 private Map<Object, NodeElement> nodeMap; 64 private Map<Object, NodeElement> nodeMap;
64 private List<EdgeElement> edgeList; 65 private List<EdgeElement> edgeList;
65 private Map<Object, NodeElement> prevNodeMap; 66 private Map<Object, NodeElement> prevNodeMap;
66 private int id; 67 private int id;
479 edgeList.add(new EdgeElement(fromNode, toNode, count, label)); 480 edgeList.add(new EdgeElement(fromNode, toNode, count, label));
480 } 481 }
481 482
482 public GraphPrintVisitor visit(Object node) { 483 public GraphPrintVisitor visit(Object node) {
483 if (openGraphCount == 0) { 484 if (openGraphCount == 0) {
484 beginGraph("truffle tree"); 485 beginGraph(DEFAULT_GRAPH_NAME);
485 } 486 }
486 487
487 // if node is visited once again, skip 488 // if node is visited once again, skip
488 if (getElementByObject(node) != null) { 489 if (getElementByObject(node) != null) {
489 return this; 490 return this;
500 501
501 return this; 502 return this;
502 } 503 }
503 504
504 public GraphPrintVisitor visit(Object node, GraphPrintHandler handler) { 505 public GraphPrintVisitor visit(Object node, GraphPrintHandler handler) {
506 if (openGraphCount == 0) {
507 beginGraph(DEFAULT_GRAPH_NAME);
508 }
509
505 handler.visit(node, new GraphPrintAdapter()); 510 handler.visit(node, new GraphPrintAdapter());
506 511
507 return this; 512 return this;
508 } 513 }
509 514