comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java @ 21407:36285949c1d5

Truffle/Instrumentation: some commentary and a new AST printing method needed for tools.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Sun, 17 May 2015 20:35:31 -0700
parents 8dc73c226c63
children 32ca2353accf
comparison
equal deleted inserted replaced
21406:b4aca5ec3f10 21407:36285949c1d5
1 /* 1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
26 26
27 import java.io.*; 27 import java.io.*;
28 import java.util.*; 28 import java.util.*;
29 29
30 import com.oracle.truffle.api.instrument.*; 30 import com.oracle.truffle.api.instrument.*;
31 import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
31 import com.oracle.truffle.api.nodes.*; 32 import com.oracle.truffle.api.nodes.*;
32 import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind; 33 import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind;
33 import com.oracle.truffle.api.source.*; 34 import com.oracle.truffle.api.source.*;
34 35
35 /** 36 /**
52 return out.toString(); 53 return out.toString();
53 } 54 }
54 55
55 public String printTreeToString(Node node, int maxDepth) { 56 public String printTreeToString(Node node, int maxDepth) {
56 return printTreeToString(node, maxDepth, null); 57 return printTreeToString(node, maxDepth, null);
58 }
59
60 public String printNodeWithInstrumentation(Node node) {
61 final StringBuilder sb = new StringBuilder();
62 if (node == null) {
63 sb.append("null");
64 } else {
65 sb.append(nodeName(node));
66 sb.append("(");
67 if (node instanceof InstrumentationNode) {
68 sb.append(instrumentInfo((InstrumentationNode) node));
69 }
70 sb.append(sourceInfo(node));
71
72 sb.append(NodeUtil.printSyntaxTags(node));
73 sb.append(")");
74 }
75 final Node parent = node.getParent();
76 if (parent instanceof WrapperNode) {
77 final WrapperNode wrapper = (WrapperNode) parent;
78 sb.append(" Probed");
79 sb.append(NodeUtil.printSyntaxTags(wrapper));
80 }
81 return sb.toString();
57 } 82 }
58 83
59 protected void printTree(PrintWriter p, Node node, int maxDepth, Node markNode, int level) { 84 protected void printTree(PrintWriter p, Node node, int maxDepth, Node markNode, int level) {
60 if (node == null) { 85 if (node == null) {
61 p.print("null"); 86 p.print("null");