Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java @ 18485:e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Sun, 23 Nov 2014 16:07:23 -0800 |
parents | 65a160d9d259 |
children | cb4d5cc2b52b |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Fri Nov 21 13:16:02 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Sun Nov 23 16:07:23 2014 -0800 @@ -33,6 +33,8 @@ import sun.misc.*; import com.oracle.truffle.api.*; +import com.oracle.truffle.api.instrument.*; +import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.nodes.Node.Children; import com.oracle.truffle.api.source.*; @@ -769,6 +771,9 @@ } sb.append(" (" + node.getClass().getSimpleName() + ") "); + + sb.append(printSyntaxTags(node)); + sb.append(displaySourceAttribution(node)); p.println(sb.toString()); @@ -798,6 +803,34 @@ } /** + * Returns a string listing the {@linkplain SyntaxTag syntax tags}, if any, associated with a + * node: + * <ul> + * <li>"[{@linkplain StandardSyntaxTag#STATEMENT STATEMENT}, + * {@linkplain StandardSyntaxTag#ASSIGNMENT ASSIGNMENT}]" if tags have been applied;</li> + * <li>"[]" if the node supports tags, but none are present; and</li> + * <li>"" if the node does not support tags.</li> + * </ul> + */ + public static String printSyntaxTags(final Object node) { + if (node instanceof WrapperNode) { + final Probe probe = ((WrapperNode) node).getProbe(); + final Collection<SyntaxTag> syntaxTags = probe.getSyntaxTags(); + final StringBuilder sb = new StringBuilder(); + String prefix = ""; + sb.append("["); + for (SyntaxTag tag : syntaxTags) { + sb.append(prefix); + prefix = ","; + sb.append(tag.toString()); + } + sb.append("]"); + return sb.toString(); + } + return ""; + } + + /** * Prints a human readable form of a {@link Node} AST to the given {@link PrintStream}. This * print method does not check for cycles in the node structure. *