annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java @ 22404:23d2b5513c83

Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Fri, 20 Nov 2015 17:27:42 +0100
parents 6598b9b7aafd
children 21f48bc8a535
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
11279
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10481
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10481
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10481
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * accompanied this code).
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 * questions.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 */
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.nodes;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
27 import java.io.BufferedOutputStream;
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
28 import java.io.ByteArrayOutputStream;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
29 import java.io.Closeable;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
30 import java.io.File;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
31 import java.io.FileOutputStream;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
32 import java.io.IOException;
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
33 import java.io.OutputStream;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
34 import java.io.PrintStream;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
35 import java.lang.annotation.ElementType;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
36 import java.lang.annotation.Retention;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
37 import java.lang.annotation.RetentionPolicy;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
38 import java.lang.annotation.Target;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
39 import java.net.Socket;
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
40 import java.nio.charset.Charset;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
41 import java.util.ArrayList;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
42 import java.util.IdentityHashMap;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
43 import java.util.LinkedHashMap;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
44 import java.util.List;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
45 import java.util.Map;
22328
d376969da381 GraphPrintVisitor: subgroup support
Andreas Woess <andreas.woess@oracle.com>
parents: 22320
diff changeset
46
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
47 import javax.xml.stream.FactoryConfigurationError;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
48 import javax.xml.stream.XMLOutputFactory;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
49 import javax.xml.stream.XMLStreamException;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
50 import javax.xml.stream.XMLStreamWriter;
22328
d376969da381 GraphPrintVisitor: subgroup support
Andreas Woess <andreas.woess@oracle.com>
parents: 22320
diff changeset
51
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
52 import com.oracle.truffle.api.TruffleOptions;
22328
d376969da381 GraphPrintVisitor: subgroup support
Andreas Woess <andreas.woess@oracle.com>
parents: 22320
diff changeset
53 import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind;
d376969da381 GraphPrintVisitor: subgroup support
Andreas Woess <andreas.woess@oracle.com>
parents: 22320
diff changeset
54
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 /**
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 * Utility class for creating output for the ideal graph visualizer.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 */
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
58 public class GraphPrintVisitor implements Closeable {
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 public static final String GraphVisualizerAddress = "127.0.0.1";
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 public static final int GraphVisualizerPort = 4444;
22355
ef3c3b62e0fc GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents: 22337
diff changeset
62 private static final String DEFAULT_GRAPH_NAME = "truffle tree";
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
64 private Map<Object, NodeElement> nodeMap;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
65 private List<EdgeElement> edgeList;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
66 private Map<Object, NodeElement> prevNodeMap;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
67 private int id;
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
68 private Impl xmlstream;
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
69 private OutputStream outputStream;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
70 private int openGroupCount;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
71 private int openGraphCount;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
72 private String currentGraphName;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
73
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
74 private static class NodeElement {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
75 private final int id;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
76 private final Map<String, Object> properties;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
77
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
78 public NodeElement(int id) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
79 super();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
80 this.id = id;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
81 this.properties = new LinkedHashMap<>();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
82 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
83
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
84 public int getId() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
85 return id;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
86 }
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
87
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
88 public Map<String, Object> getProperties() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
89 return properties;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
90 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
91 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
92
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
93 private static class EdgeElement {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
94 private final NodeElement from;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
95 private final NodeElement to;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
96 private final int index;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
97 private final String label;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
98
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
99 public EdgeElement(NodeElement from, NodeElement to, int index, String label) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
100 this.from = from;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
101 this.to = to;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
102 this.index = index;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
103 this.label = label;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
104 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
105
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
106 public NodeElement getFrom() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
107 return from;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
108 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
109
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
110 public NodeElement getTo() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
111 return to;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
112 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
113
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
114 public int getIndex() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
115 return index;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
116 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
117
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
118 public String getLabel() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
119 return label;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
120 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
121 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122
22363
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
123 private interface Impl {
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
124 void writeStartDocument();
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
125
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
126 void writeEndDocument();
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
127
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
128 void writeStartElement(String name);
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
129
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
130 void writeEndElement();
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
131
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
132 void writeAttribute(String name, String value);
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
133
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
134 void writeCharacters(String text);
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
135
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
136 void flush();
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
137
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
138 void close();
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
139 }
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
140
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
141 private static class XMLImpl implements Impl {
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
142 private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
143 private final XMLStreamWriter xmlstream;
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
144
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
145 XMLImpl(OutputStream outputStream) {
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
146 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
147 this.xmlstream = XML_OUTPUT_FACTORY.createXMLStreamWriter(outputStream);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
148 } catch (XMLStreamException | FactoryConfigurationError e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
149 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
150 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
151 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
152
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
153 public void writeStartDocument() {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
154 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
155 xmlstream.writeStartDocument();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
156 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
157 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
158 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
159 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
160
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
161 public void writeEndDocument() {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
162 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
163 xmlstream.writeEndDocument();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
164 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
165 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
166 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
167 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
168
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
169 public void writeStartElement(String name) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
170 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
171 xmlstream.writeStartElement(name);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
172 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
173 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
174 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
175 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
176
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
177 public void writeEndElement() {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
178 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
179 xmlstream.writeEndElement();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
180 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
181 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
182 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
183 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
184
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
185 public void writeAttribute(String name, String value) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
186 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
187 xmlstream.writeAttribute(name, value);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
188 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
189 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
190 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
191 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
192
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
193 public void writeCharacters(String text) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
194 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
195 xmlstream.writeCharacters(text);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
196 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
197 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
198 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
199 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
200
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
201 public void flush() {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
202 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
203 xmlstream.flush();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
204 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
205 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
206 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
207 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
208
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
209 public void close() {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
210 try {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
211 xmlstream.close();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
212 } catch (XMLStreamException e) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
213 throw new RuntimeException(e);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
214 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
215 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
216 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
217
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 public GraphPrintVisitor() {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
219 this(new ByteArrayOutputStream());
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
220 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
222 public GraphPrintVisitor(OutputStream outputStream) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
223 this.outputStream = outputStream;
22363
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
224 this.xmlstream = createImpl(outputStream);
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
225 this.xmlstream.writeStartDocument();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
226 this.xmlstream.writeStartElement("graphDocument");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
227 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
228
22363
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
229 private static Impl createImpl(OutputStream outputStream) {
22370
4b1005e85f94 Partially backed out changeset: a360c82ba357
Andreas Woess <andreas.woess@oracle.com>
parents: 22368
diff changeset
230 return new XMLImpl(outputStream);
22363
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
231 }
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
232
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
233 private void ensureOpen() {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
234 if (xmlstream == null) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
235 throw new IllegalStateException("printer is closed");
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
236 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 public GraphPrintVisitor beginGroup(String groupName) {
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
240 ensureOpen();
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
241 maybeEndGraph();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
242 openGroupCount++;
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
243 xmlstream.writeStartElement("group");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
244 xmlstream.writeStartElement("properties");
22328
d376969da381 GraphPrintVisitor: subgroup support
Andreas Woess <andreas.woess@oracle.com>
parents: 22320
diff changeset
245
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
246 if (!groupName.isEmpty()) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
247 // set group name
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
248 xmlstream.writeStartElement("p");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
249 xmlstream.writeAttribute("name", "name");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
250 xmlstream.writeCharacters(groupName);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
251 xmlstream.writeEndElement();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
252 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
254 xmlstream.writeEndElement(); // properties
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
255
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
256 // forget old nodes
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
257 prevNodeMap = null;
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
258 nodeMap = new IdentityHashMap<>();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
259 edgeList = new ArrayList<>();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
260
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
261 return this;
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
262 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
264 public GraphPrintVisitor endGroup() {
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
265 ensureOpen();
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
266 if (openGroupCount <= 0) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
267 throw new IllegalArgumentException("no open group");
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
268 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
269 maybeEndGraph();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
270 openGroupCount--;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
271
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
272 xmlstream.writeEndElement(); // group
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
274 return this;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 public GraphPrintVisitor beginGraph(String graphName) {
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
278 ensureOpen();
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
279 if (openGroupCount == 0) {
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
280 beginGroup(graphName);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 }
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
282 maybeEndGraph();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
283 openGraphCount++;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
285 this.currentGraphName = graphName;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 // save old nodes
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 prevNodeMap = nodeMap;
18872
7735bac1f781 Truffle: IGV printer nodeMap should be IdentityHashMap
Andreas Woess <andreas.woess@jku.at>
parents: 17401
diff changeset
289 nodeMap = new IdentityHashMap<>();
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 edgeList = new ArrayList<>();
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 return this;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
295 private void maybeEndGraph() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
296 if (openGraphCount > 0) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
297 endGraph();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
298 assert openGraphCount == 0;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
299 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
300 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
301
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
302 public GraphPrintVisitor endGraph() {
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
303 ensureOpen();
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
304 if (openGraphCount <= 0) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
305 throw new IllegalArgumentException("no open graph");
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
306 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
307 openGraphCount--;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
308
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
309 xmlstream.writeStartElement("graph");
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
310
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
311 xmlstream.writeStartElement("properties");
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
312
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
313 // set graph name
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
314 xmlstream.writeStartElement("p");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
315 xmlstream.writeAttribute("name", "name");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
316 xmlstream.writeCharacters(currentGraphName);
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
317 xmlstream.writeEndElement();
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
318
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
319 xmlstream.writeEndElement(); // properties
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
320
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
321 xmlstream.writeStartElement("nodes");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
322 writeNodes();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
323 xmlstream.writeEndElement(); // nodes
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
324
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
325 xmlstream.writeStartElement("edges");
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
326 writeEdges();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
327 xmlstream.writeEndElement(); // edges
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
328
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
329 xmlstream.writeEndElement(); // graph
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
330
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
331 xmlstream.flush();
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
332
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
333 return this;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
334 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
335
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
336 private void writeNodes() {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
337 for (NodeElement node : nodeMap.values()) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
338 xmlstream.writeStartElement("node");
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
339 xmlstream.writeAttribute("id", String.valueOf(node.getId()));
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
340
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
341 xmlstream.writeStartElement("properties");
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
342 for (Map.Entry<String, Object> property : node.getProperties().entrySet()) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
343 xmlstream.writeStartElement("p");
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
344 xmlstream.writeAttribute("name", property.getKey());
22337
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
345 xmlstream.writeCharacters(safeToString(property.getValue()));
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
346 xmlstream.writeEndElement(); // p
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
347 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
348 xmlstream.writeEndElement(); // properties
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
349
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
350 xmlstream.writeEndElement(); // node
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
351 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
352 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
353
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
354 private void writeEdges() {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
355 for (EdgeElement edge : edgeList) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
356 xmlstream.writeStartElement("edge");
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
357
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
358 xmlstream.writeAttribute("from", String.valueOf(edge.getFrom().getId()));
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
359 xmlstream.writeAttribute("to", String.valueOf(edge.getTo().getId()));
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
360 xmlstream.writeAttribute("index", String.valueOf(edge.getIndex()));
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
361 if (edge.getLabel() != null) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
362 xmlstream.writeAttribute("label", edge.getLabel());
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
363 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
364
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
365 xmlstream.writeEndElement(); // edge
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
366 }
22328
d376969da381 GraphPrintVisitor: subgroup support
Andreas Woess <andreas.woess@oracle.com>
parents: 22320
diff changeset
367 }
d376969da381 GraphPrintVisitor: subgroup support
Andreas Woess <andreas.woess@oracle.com>
parents: 22320
diff changeset
368
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 @Override
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 public String toString() {
22370
4b1005e85f94 Partially backed out changeset: a360c82ba357
Andreas Woess <andreas.woess@oracle.com>
parents: 22368
diff changeset
371 if (outputStream instanceof ByteArrayOutputStream) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
372 return new String(((ByteArrayOutputStream) outputStream).toByteArray(), Charset.forName("UTF-8"));
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 }
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
374 return super.toString();
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 public void printToFile(File f) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
378 close();
22370
4b1005e85f94 Partially backed out changeset: a360c82ba357
Andreas Woess <andreas.woess@oracle.com>
parents: 22368
diff changeset
379 if (outputStream instanceof ByteArrayOutputStream) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
380 try (OutputStream os = new FileOutputStream(f)) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
381 os.write(((ByteArrayOutputStream) outputStream).toByteArray());
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
382 } catch (IOException e) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
383 e.printStackTrace();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
384 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 public void printToSysout() {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
389 close();
22370
4b1005e85f94 Partially backed out changeset: a360c82ba357
Andreas Woess <andreas.woess@oracle.com>
parents: 22368
diff changeset
390 if (outputStream instanceof ByteArrayOutputStream) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
391 PrintStream out = System.out;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
392 out.println(toString());
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11637
diff changeset
396 public void printToNetwork(boolean ignoreErrors) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
397 close();
22370
4b1005e85f94 Partially backed out changeset: a360c82ba357
Andreas Woess <andreas.woess@oracle.com>
parents: 22368
diff changeset
398 if (outputStream instanceof ByteArrayOutputStream) {
22363
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
399 try (Socket socket = new Socket(GraphVisualizerAddress, GraphVisualizerPort); BufferedOutputStream os = new BufferedOutputStream(socket.getOutputStream(), 0x4000)) {
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
400 os.write(((ByteArrayOutputStream) outputStream).toByteArray());
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
401 } catch (IOException e) {
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
402 if (!ignoreErrors) {
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
403 e.printStackTrace();
a360c82ba357 GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents: 22355
diff changeset
404 }
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11637
diff changeset
405 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
406 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
409 public void close() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
410 if (xmlstream == null) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
411 return;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
412 }
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
413 while (openGroupCount > 0) {
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
414 endGroup();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
415 }
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
416 assert openGraphCount == 0 && openGroupCount == 0;
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
417
22332
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
418 xmlstream.writeEndElement(); // graphDocument
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
419 xmlstream.writeEndDocument();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
420 xmlstream.flush();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
421 xmlstream.close();
fdc687bad5d4 GraphPrintVisitor: factor out implementation
Andreas Woess <andreas.woess@oracle.com>
parents: 22331
diff changeset
422 xmlstream = null;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
425 private int nextId() {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
426 return id++;
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
427 }
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
428
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
429 private int oldOrNextId(Object node) {
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 if (null != prevNodeMap && prevNodeMap.containsKey(node)) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
431 NodeElement nodeElem = prevNodeMap.get(node);
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
432 return nodeElem.getId();
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 } else {
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 return nextId();
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
438 /**
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
439 * @deprecated to be removed
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
440 */
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
441 @Deprecated
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
442 protected Object getElementByObject(Object obj) {
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
443 return getElementByObjectImpl(obj);
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
444 }
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
445
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
446 final NodeElement getElementByObjectImpl(Object obj) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
447 return nodeMap.get(obj);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
450 /**
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
451 * @deprecated to be removed
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
452 */
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
453 @Deprecated
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 protected void createElementForNode(Object node) {
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 boolean exists = nodeMap.containsKey(node);
22320
5ee16f4908e5 Remove obsolete, unused classes
Andreas Woess <andreas.woess@oracle.com>
parents: 22157
diff changeset
456 if (!exists) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
457 int nodeId = !exists ? oldOrNextId(node) : nextId();
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
458 nodeMap.put(node, new NodeElement(nodeId));
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
460 setNodePropertyImpl(node, "name", node.getClass().getSimpleName().replaceFirst("Node$", ""));
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 NodeInfo nodeInfo = node.getClass().getAnnotation(NodeInfo.class);
10481
29e9a5d18c70 Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9754
diff changeset
462 if (nodeInfo != null) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
463 setNodePropertyImpl(node, "cost", nodeInfo.cost());
10481
29e9a5d18c70 Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9754
diff changeset
464 if (!nodeInfo.shortName().isEmpty()) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
465 setNodePropertyImpl(node, "shortName", nodeInfo.shortName());
10481
29e9a5d18c70 Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9754
diff changeset
466 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 }
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
468 setNodePropertyImpl(node, "class", node.getClass().getSimpleName());
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
469 if (node instanceof Node) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
470 readNodeProperties((Node) node);
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
471 copyDebugProperties((Node) node);
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
472 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
476 /**
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
477 * @deprecated to be removed
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
478 */
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
479 @Deprecated
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 protected void setNodeProperty(Object node, String propertyName, Object value) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
481 setNodePropertyImpl(node, propertyName, value);
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
482 }
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
483
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
484 final void setNodePropertyImpl(Object node, String propertyName, Object value) {
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
485 NodeElement nodeElem = getElementByObjectImpl(node);
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
486 nodeElem.getProperties().put(propertyName, value);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
489 private void copyDebugProperties(Node node) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
490 Map<String, Object> debugProperties = node.getDebugProperties();
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
491 for (Map.Entry<String, Object> property : debugProperties.entrySet()) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
492 setNodePropertyImpl(node, property.getKey(), property.getValue());
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495
9754
98b004bf3985 Refactoring of NodeUtil to centralize the use of reflection
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9537
diff changeset
496 private void readNodeProperties(Node node) {
22372
6598b9b7aafd Backed out changeset: 0d4b0e4263ee
Christian Wirth <christian.wirth@oracle.com>
parents: 22370
diff changeset
497 NodeFieldAccessor[] fields = NodeClass.get(node).getFields();
20129
5b7db8941fd7 Truffle: make NodeClass and NodeField a top-level class.
Christian Humer <christian.humer@gmail.com>
parents: 18872
diff changeset
498 for (NodeFieldAccessor field : fields) {
9754
98b004bf3985 Refactoring of NodeUtil to centralize the use of reflection
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9537
diff changeset
499 if (field.getKind() == NodeFieldKind.DATA) {
98b004bf3985 Refactoring of NodeUtil to centralize the use of reflection
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9537
diff changeset
500 String key = field.getName();
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
501 if (!getElementByObjectImpl(node).getProperties().containsKey(key)) {
9754
98b004bf3985 Refactoring of NodeUtil to centralize the use of reflection
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9537
diff changeset
502 Object value = field.loadValue(node);
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
503 setNodePropertyImpl(node, key, value);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
504 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
509 /**
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
510 * @deprecated to be removed
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
511 */
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
512 @Deprecated
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
513 protected void connectNodes(Object a, Object b, String label) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
514 connectNodesImpl(a, b, label);
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
515 }
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
516
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
517 final void connectNodesImpl(Object a, Object b, String label) {
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
518 NodeElement fromNode = getElementByObjectImpl(a);
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
519 NodeElement toNode = getElementByObjectImpl(b);
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
520 if (fromNode == null || toNode == null) {
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521 return;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 // count existing to-edges
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 int count = 0;
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
526 for (EdgeElement e : edgeList) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
527 if (e.getTo() == toNode) {
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 ++count;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
532 edgeList.add(new EdgeElement(fromNode, toNode, count, label));
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 public GraphPrintVisitor visit(Object node) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
536 if (openGraphCount == 0) {
22355
ef3c3b62e0fc GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents: 22337
diff changeset
537 beginGraph(DEFAULT_GRAPH_NAME);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
538 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
539
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
540 // if node is visited once again, skip
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
541 if (getElementByObjectImpl(node) != null) {
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
542 return this;
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
543 }
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
544
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
545 // respect node's custom handler
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
546 if (!TruffleOptions.AOT && NodeUtil.findAnnotation(node.getClass(), CustomGraphPrintHandler.class) != null) {
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
547 visit(node, createGraphPrintHandlerFromClass(NodeUtil.findAnnotation(node.getClass(), CustomGraphPrintHandler.class).handler()));
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
548 } else if (NodeUtil.findAnnotation(node.getClass(), NullGraphPrintHandler.class) != null) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
549 // ignore
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
550 } else {
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
551 visit(node, new DefaultGraphPrintHandler());
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
554 return this;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
555 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
557 public GraphPrintVisitor visit(Object node, GraphPrintHandler handler) {
22355
ef3c3b62e0fc GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents: 22337
diff changeset
558 if (openGraphCount == 0) {
ef3c3b62e0fc GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents: 22337
diff changeset
559 beginGraph(DEFAULT_GRAPH_NAME);
ef3c3b62e0fc GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents: 22337
diff changeset
560 }
ef3c3b62e0fc GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents: 22337
diff changeset
561
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
562 handler.visit(node, new GraphPrintAdapter());
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
563
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
564 return this;
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
565 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
566
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
567 private static GraphPrintHandler createGraphPrintHandlerFromClass(Class<? extends GraphPrintHandler> customHandlerClass) {
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
568 try {
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
569 return customHandlerClass.newInstance();
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
570 } catch (InstantiationException | IllegalAccessException e) {
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
571 throw new AssertionError(e);
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
572 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
573 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
574
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
575 private static LinkedHashMap<String, Node> findNamedNodeChildren(Node node) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
576 LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
22372
6598b9b7aafd Backed out changeset: 0d4b0e4263ee
Christian Wirth <christian.wirth@oracle.com>
parents: 22370
diff changeset
577 NodeClass nodeClass = NodeClass.get(node);
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
578
20129
5b7db8941fd7 Truffle: make NodeClass and NodeField a top-level class.
Christian Humer <christian.humer@gmail.com>
parents: 18872
diff changeset
579 for (NodeFieldAccessor field : nodeClass.getFields()) {
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
580 NodeFieldKind kind = field.getKind();
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
581 if (kind == NodeFieldKind.CHILD || kind == NodeFieldKind.CHILDREN) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
582 Object value = field.loadValue(node);
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
583 if (value != null) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
584 if (kind == NodeFieldKind.CHILD) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
585 nodes.put(field.getName(), (Node) value);
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
586 } else if (kind == NodeFieldKind.CHILDREN) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
587 Object[] children = (Object[]) value;
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
588 for (int i = 0; i < children.length; i++) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
589 if (children[i] != null) {
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
590 nodes.put(field.getName() + "[" + i + "]", (Node) children[i]);
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
591 }
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
592 }
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
593 }
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
594 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
595 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
597
11637
126e20d36563 Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents: 11279
diff changeset
598 return nodes;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
599 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
600
22337
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
601 private static String safeToString(Object value) {
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
602 try {
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
603 return String.valueOf(value);
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
604 } catch (Throwable ex) {
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
605 return value.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(value));
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
606 }
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
607 }
4f3eda22dbe9 make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents: 22332
diff changeset
608
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
609 public class GraphPrintAdapter {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
610
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611 public void createElementForNode(Object node) {
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612 GraphPrintVisitor.this.createElementForNode(node);
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
613 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
614
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
615 public void visit(Object node) {
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
616 GraphPrintVisitor.this.visit(node);
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
617 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
618
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
619 public void visit(Object node, GraphPrintHandler handler) {
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
620 GraphPrintVisitor.this.visit(node, handler);
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
621 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
622
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623 public void connectNodes(Object node, Object child) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
624 GraphPrintVisitor.this.connectNodesImpl(node, child, null);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
625 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
626
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
627 public void connectNodes(Object node, Object child, String label) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
628 GraphPrintVisitor.this.connectNodesImpl(node, child, label);
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
629 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
630
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
631 public void setNodeProperty(Object node, String propertyName, Object value) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
632 GraphPrintVisitor.this.setNodePropertyImpl(node, propertyName, value);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
633 }
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
634
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
635 public boolean visited(Object node) {
22404
23d2b5513c83 Fixing API error: GraphPrintVisitor shouldn't expose internal API class in an API method. When at it deprecating all protected methods, as GraphPrintVisitor usages don't indicate somebody should be subclassing it at all.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22372
diff changeset
636 return GraphPrintVisitor.this.getElementByObjectImpl(node) != null;
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
637 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
638 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
639
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
640 public interface GraphPrintHandler {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
641
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
642 void visit(Object node, GraphPrintAdapter printer);
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
643 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
644
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
645 private static final class DefaultGraphPrintHandler implements GraphPrintHandler {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
646 public void visit(Object node, GraphPrintAdapter printer) {
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
647 printer.createElementForNode(node);
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
648
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
649 if (node instanceof Node) {
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
650 for (Map.Entry<String, Node> child : findNamedNodeChildren((Node) node).entrySet()) {
22331
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
651 printer.visit(child.getValue());
920c3ec54499 GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents: 22329
diff changeset
652 printer.connectNodes(node, child.getValue(), child.getKey());
22329
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
653 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
654 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
655 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
656 }
0981139c6a29 GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents: 22328
diff changeset
657
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
658 @Retention(RetentionPolicy.RUNTIME)
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
659 @Target(ElementType.TYPE)
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
660 public @interface CustomGraphPrintHandler {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
661
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
662 Class<? extends GraphPrintHandler> handler();
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
663 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
664
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
665 @Retention(RetentionPolicy.RUNTIME)
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
666 @Target(ElementType.TYPE)
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
667 public @interface NullGraphPrintHandler {
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
668 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
669 }