Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/DefaultRubyNodeInstrumenter.java @ 13735:2c1c805153e6
Ruby: refactor low level instrumentation services
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 22 Jan 2014 21:02:06 -0800 |
parents | |
children | 22bf5a8ba9eb |
comparison
equal
deleted
inserted
replaced
13734:7bab96d62fa3 | 13735:2c1c805153e6 |
---|---|
1 /* | |
2 * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This | |
3 * code is released under a tri EPL/GPL/LGPL license. You can use it, | |
4 * redistribute it and/or modify it under the terms of the: | |
5 * | |
6 * Eclipse Public License version 1.0 | |
7 * GNU General Public License version 2 | |
8 * GNU Lesser General Public License version 2.1 | |
9 */ | |
10 package com.oracle.truffle.ruby.parser; | |
11 | |
12 import com.oracle.truffle.api.nodes.instrument.*; | |
13 import com.oracle.truffle.ruby.nodes.*; | |
14 import com.oracle.truffle.ruby.nodes.debug.*; | |
15 import com.oracle.truffle.ruby.runtime.*; | |
16 import com.oracle.truffle.ruby.runtime.debug.*; | |
17 import com.oracle.truffle.ruby.runtime.methods.*; | |
18 | |
19 /** | |
20 * Utility for instrumenting Ruby AST nodes to support the language's built-in <A | |
21 * href="http://www.ruby-doc.org/core-2.0.0/Kernel.html#method-i-set_trace_func">tracing | |
22 * facility</A>. It ignores nodes other than {@linkplain NodePhylum#STATEMENT statements}. | |
23 */ | |
24 final class DefaultRubyNodeInstrumenter implements RubyNodeInstrumenter { | |
25 | |
26 public DefaultRubyNodeInstrumenter() { | |
27 } | |
28 | |
29 public RubyNode instrumentAsStatement(RubyNode rubyNode) { | |
30 assert rubyNode != null; | |
31 assert !(rubyNode instanceof RubyProxyNode); | |
32 final RubyContext context = rubyNode.getContext(); | |
33 if (context.getConfiguration().getTrace()) { | |
34 final RubyProxyNode proxy = new RubyProxyNode(context, rubyNode); | |
35 proxy.markAs(NodePhylum.STATEMENT); | |
36 proxy.getProbeChain().appendProbe(new RubyTraceProbe(context)); | |
37 return proxy; | |
38 } | |
39 return rubyNode; | |
40 } | |
41 | |
42 public RubyNode instrumentAsCall(RubyNode node, String callName) { | |
43 return node; | |
44 } | |
45 | |
46 public RubyNode instrumentAsLocalAssignment(RubyNode node, UniqueMethodIdentifier methodIdentifier, String localName) { | |
47 return node; | |
48 } | |
49 | |
50 } |