Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLDefaultVisualizer.java @ 16595:618d92152d3c
SL: Added support for instrumentation.
author | David Piorkowski <david.piorkowski@oracle.com> |
---|---|
date | Thu, 24 Jul 2014 16:14:44 -0700 |
parents | |
children | ef30b2318658 |
comparison
equal
deleted
inserted
replaced
16592:8084d44c78d3 | 16595:618d92152d3c |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.sl.nodes.instrument; | |
24 | |
25 import com.oracle.truffle.api.*; | |
26 import com.oracle.truffle.api.frame.*; | |
27 import com.oracle.truffle.api.instrument.*; | |
28 import com.oracle.truffle.api.instrument.impl.*; | |
29 import com.oracle.truffle.api.nodes.*; | |
30 import com.oracle.truffle.sl.nodes.*; | |
31 import com.oracle.truffle.sl.runtime.*; | |
32 | |
33 /** | |
34 * SLDefaultVisualizer provides methods to get the names of SL's internal Truffle AST nodes. | |
35 * | |
36 */ | |
37 public class SLDefaultVisualizer extends DefaultVisualizer { | |
38 | |
39 private final SLASTPrinter astPrinter; | |
40 | |
41 public SLDefaultVisualizer() { | |
42 this.astPrinter = new SLASTPrinter(); | |
43 } | |
44 | |
45 @Override | |
46 public ASTPrinter getASTPrinter() { | |
47 return astPrinter; | |
48 } | |
49 | |
50 @Override | |
51 public String displayMethodName(Node node) { | |
52 | |
53 if (node == null) { | |
54 return null; | |
55 } | |
56 RootNode root = node.getRootNode(); | |
57 if (root instanceof SLRootNode) { | |
58 SLRootNode slRootNode = (SLRootNode) root; | |
59 return slRootNode.toString(); | |
60 | |
61 } | |
62 return "unknown"; | |
63 } | |
64 | |
65 @Override | |
66 public String displayCallTargetName(CallTarget callTarget) { | |
67 if (callTarget instanceof RootCallTarget) { | |
68 final RootCallTarget rootCallTarget = (RootCallTarget) callTarget; | |
69 SLRootNode slRootNode = (SLRootNode) rootCallTarget.getRootNode(); | |
70 return slRootNode.toString(); | |
71 } | |
72 return callTarget.toString(); | |
73 } | |
74 | |
75 @Override | |
76 public String displayValue(ExecutionContext context, Object value) { | |
77 if (value == SLNull.SINGLETON) { | |
78 return "null"; | |
79 } | |
80 return value.toString(); | |
81 } | |
82 | |
83 @Override | |
84 public String displayIdentifier(FrameSlot slot) { | |
85 | |
86 final Object id = slot.getIdentifier(); | |
87 return id.toString(); | |
88 } | |
89 } |