Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java @ 22372:6598b9b7aafd
Backed out changeset: 0d4b0e4263ee
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Tue, 17 Nov 2015 11:02:55 +0100 |
parents | 4b1005e85f94 |
children | 23d2b5513c83 |
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 |
22363
a360c82ba357
GraphPrintVisitor implementation can now be disabled via system property
Andreas Woess <andreas.woess@oracle.com>
parents:
22355
diff
changeset
|
145 protected 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 |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
438 protected NodeElement getElementByObject(Object obj) { |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
439 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
|
440 } |
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
|
441 |
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
|
442 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
|
443 boolean exists = nodeMap.containsKey(node); |
22320
5ee16f4908e5
Remove obsolete, unused classes
Andreas Woess <andreas.woess@oracle.com>
parents:
22157
diff
changeset
|
444 if (!exists) { |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
445 int nodeId = !exists ? oldOrNextId(node) : nextId(); |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
446 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
|
447 |
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 setNodeProperty(node, "name", node.getClass().getSimpleName().replaceFirst("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
|
449 NodeInfo nodeInfo = node.getClass().getAnnotation(NodeInfo.class); |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9754
diff
changeset
|
450 if (nodeInfo != null) { |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
451 setNodeProperty(node, "cost", nodeInfo.cost()); |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9754
diff
changeset
|
452 if (!nodeInfo.shortName().isEmpty()) { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9754
diff
changeset
|
453 setNodeProperty(node, "shortName", nodeInfo.shortName()); |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9754
diff
changeset
|
454 } |
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
|
455 } |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9754
diff
changeset
|
456 setNodeProperty(node, "class", node.getClass().getSimpleName()); |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
457 if (node instanceof Node) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
458 readNodeProperties((Node) node); |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
459 copyDebugProperties((Node) node); |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
460 } |
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 } |
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
|
462 } |
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
|
463 |
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
|
464 protected void setNodeProperty(Object node, String propertyName, Object value) { |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
465 NodeElement nodeElem = getElementByObject(node); |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
466 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
|
467 } |
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
|
468 |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
469 private void copyDebugProperties(Node node) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
470 Map<String, Object> debugProperties = node.getDebugProperties(); |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
471 for (Map.Entry<String, Object> property : debugProperties.entrySet()) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
472 setNodeProperty(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
|
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 |
9754
98b004bf3985
Refactoring of NodeUtil to centralize the use of reflection
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9537
diff
changeset
|
476 private void readNodeProperties(Node node) { |
22372
6598b9b7aafd
Backed out changeset: 0d4b0e4263ee
Christian Wirth <christian.wirth@oracle.com>
parents:
22370
diff
changeset
|
477 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
|
478 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
|
479 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
|
480 String key = field.getName(); |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
481 if (!getElementByObject(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
|
482 Object value = field.loadValue(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
|
483 setNodeProperty(node, key, value); |
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
|
484 } |
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
|
485 } |
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
|
486 } |
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 protected void connectNodes(Object a, Object b, String label) { |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
490 NodeElement fromNode = getElementByObject(a); |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
491 NodeElement toNode = getElementByObject(b); |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
492 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
|
493 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
|
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 |
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
|
496 // 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
|
497 int count = 0; |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
498 for (EdgeElement e : edgeList) { |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
499 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
|
500 ++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
|
501 } |
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
|
502 } |
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
|
503 |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
504 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
|
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 public GraphPrintVisitor visit(Object node) { |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
508 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
|
509 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
|
510 } |
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
|
511 |
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
|
512 // if node is visited once again, skip |
22320
5ee16f4908e5
Remove obsolete, unused classes
Andreas Woess <andreas.woess@oracle.com>
parents:
22157
diff
changeset
|
513 if (getElementByObject(node) != null) { |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
514 return this; |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
515 } |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
516 |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
517 // respect node's custom handler |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
518 if (!TruffleOptions.AOT && NodeUtil.findAnnotation(node.getClass(), CustomGraphPrintHandler.class) != null) { |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
519 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
|
520 } 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
|
521 // ignore |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
522 } else { |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
523 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
|
524 } |
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 |
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
|
526 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
|
527 } |
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 |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
529 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
|
530 if (openGraphCount == 0) { |
ef3c3b62e0fc
GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents:
22337
diff
changeset
|
531 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
|
532 } |
ef3c3b62e0fc
GraphPrintVisitor: begin a graph if visit is called without beginGraph
Andreas Woess <andreas.woess@oracle.com>
parents:
22337
diff
changeset
|
533 |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
534 handler.visit(node, new GraphPrintAdapter()); |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
535 |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
536 return this; |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
537 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
538 |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
539 private static GraphPrintHandler createGraphPrintHandlerFromClass(Class<? extends GraphPrintHandler> customHandlerClass) { |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
540 try { |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
541 return customHandlerClass.newInstance(); |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
542 } catch (InstantiationException | IllegalAccessException e) { |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
543 throw new AssertionError(e); |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
544 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
545 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
546 |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
547 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
|
548 LinkedHashMap<String, Node> nodes = new LinkedHashMap<>(); |
22372
6598b9b7aafd
Backed out changeset: 0d4b0e4263ee
Christian Wirth <christian.wirth@oracle.com>
parents:
22370
diff
changeset
|
549 NodeClass nodeClass = NodeClass.get(node); |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
550 |
20129
5b7db8941fd7
Truffle: make NodeClass and NodeField a top-level class.
Christian Humer <christian.humer@gmail.com>
parents:
18872
diff
changeset
|
551 for (NodeFieldAccessor field : nodeClass.getFields()) { |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
552 NodeFieldKind kind = field.getKind(); |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
553 if (kind == NodeFieldKind.CHILD || kind == NodeFieldKind.CHILDREN) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
554 Object value = field.loadValue(node); |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
555 if (value != null) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
556 if (kind == NodeFieldKind.CHILD) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
557 nodes.put(field.getName(), (Node) value); |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
558 } else if (kind == NodeFieldKind.CHILDREN) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
559 Object[] children = (Object[]) value; |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
560 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
|
561 if (children[i] != null) { |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
562 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
|
563 } |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
564 } |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
565 } |
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
566 } |
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
|
567 } |
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
|
568 } |
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
|
569 |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
570 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
|
571 } |
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
|
572 |
22337
4f3eda22dbe9
make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents:
22332
diff
changeset
|
573 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
|
574 try { |
4f3eda22dbe9
make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents:
22332
diff
changeset
|
575 return String.valueOf(value); |
4f3eda22dbe9
make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents:
22332
diff
changeset
|
576 } catch (Throwable ex) { |
4f3eda22dbe9
make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents:
22332
diff
changeset
|
577 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
|
578 } |
4f3eda22dbe9
make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents:
22332
diff
changeset
|
579 } |
4f3eda22dbe9
make GraphPrintVisitor resilient against toString() methods that throw
Andreas Woess <andreas.woess@oracle.com>
parents:
22332
diff
changeset
|
580 |
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
|
581 public class GraphPrintAdapter { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
582 |
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
|
583 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
|
584 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
|
585 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
586 |
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
|
587 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
|
588 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
|
589 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
590 |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
591 public void visit(Object node, GraphPrintHandler handler) { |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
592 GraphPrintVisitor.this.visit(node, handler); |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
593 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
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 public void connectNodes(Object node, Object child) { |
11637
126e20d36563
Truffle IGV printer: add edge labels.
Andreas Woess <andreas.woess@jku.at>
parents:
11279
diff
changeset
|
596 GraphPrintVisitor.this.connectNodes(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
|
597 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
598 |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
599 public void connectNodes(Object node, Object child, String label) { |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
600 GraphPrintVisitor.this.connectNodes(node, child, label); |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
601 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
602 |
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
|
603 public void setNodeProperty(Object node, String propertyName, Object value) { |
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
|
604 GraphPrintVisitor.this.setNodeProperty(node, propertyName, value); |
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
|
605 } |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
606 |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
607 public boolean visited(Object node) { |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
608 return GraphPrintVisitor.this.getElementByObject(node) != null; |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
609 } |
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
|
610 } |
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 |
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 public interface GraphPrintHandler { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
613 |
22331
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
614 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
|
615 } |
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 |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
617 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
|
618 public void visit(Object node, GraphPrintAdapter printer) { |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
619 printer.createElementForNode(node); |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
620 |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
621 if (node instanceof Node) { |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
622 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
|
623 printer.visit(child.getValue()); |
920c3ec54499
GraphPrintVisitor rewrite using javax.xml.stream
Andreas Woess <andreas.woess@oracle.com>
parents:
22329
diff
changeset
|
624 printer.connectNodes(node, child.getValue(), child.getKey()); |
22329
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
625 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
626 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
627 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
628 } |
0981139c6a29
GraphPrintVisitor: refactoring
Andreas Woess <andreas.woess@oracle.com>
parents:
22328
diff
changeset
|
629 |
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
|
630 @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
|
631 @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
|
632 public @interface CustomGraphPrintHandler { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
633 |
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
|
634 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
|
635 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
636 |
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
|
637 @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
|
638 @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
|
639 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
|
640 } |
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
|
641 } |