diff graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/DefaultRubyNodeInstrumenter.java @ 13918:22bf5a8ba9eb

Ruby: restore prototype debugger.
author Chris Seaton <chris.seaton@oracle.com>
date Mon, 10 Feb 2014 03:39:21 +0000
parents 2c1c805153e6
children
line wrap: on
line diff
--- a/graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/DefaultRubyNodeInstrumenter.java	Mon Feb 10 03:37:32 2014 +0000
+++ b/graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/DefaultRubyNodeInstrumenter.java	Mon Feb 10 03:39:21 2014 +0000
@@ -9,7 +9,9 @@
  */
 package com.oracle.truffle.ruby.parser;
 
+import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.nodes.instrument.*;
+import com.oracle.truffle.api.source.*;
 import com.oracle.truffle.ruby.nodes.*;
 import com.oracle.truffle.ruby.nodes.debug.*;
 import com.oracle.truffle.ruby.runtime.*;
@@ -26,17 +28,33 @@
     public DefaultRubyNodeInstrumenter() {
     }
 
-    public RubyNode instrumentAsStatement(RubyNode rubyNode) {
-        assert rubyNode != null;
-        assert !(rubyNode instanceof RubyProxyNode);
-        final RubyContext context = rubyNode.getContext();
+    public RubyNode instrumentAsStatement(RubyNode node) {
+        assert node != null;
+
+        final RubyContext context = node.getContext();
+
+        RubyProxyNode proxy;
+
+        if (node instanceof RubyProxyNode) {
+            proxy = (RubyProxyNode) node;
+        } else {
+            proxy = new RubyProxyNode(node.getContext(), node);
+            proxy.markAs(NodePhylum.STATEMENT);
+            proxy.clearSourceSection();
+            proxy.assignSourceSection(node.getSourceSection());
+        }
+
         if (context.getConfiguration().getTrace()) {
-            final RubyProxyNode proxy = new RubyProxyNode(context, rubyNode);
-            proxy.markAs(NodePhylum.STATEMENT);
             proxy.getProbeChain().appendProbe(new RubyTraceProbe(context));
-            return proxy;
         }
-        return rubyNode;
+
+        if (context.getConfiguration().getDebug()) {
+            final SourceSection sourceSection = proxy.getChild().getSourceSection();
+            final SourceLineLocation sourceLine = new SourceLineLocation(sourceSection.getSource(), sourceSection.getStartLine());
+            proxy.getProbeChain().appendProbe(new InactiveLineDebugProbe(context, sourceLine, context.getRubyDebugManager().getAssumption(sourceLine)));
+        }
+
+        return proxy;
     }
 
     public RubyNode instrumentAsCall(RubyNode node, String callName) {
@@ -44,7 +62,27 @@
     }
 
     public RubyNode instrumentAsLocalAssignment(RubyNode node, UniqueMethodIdentifier methodIdentifier, String localName) {
-        return node;
+        assert node != null;
+
+        final RubyContext context = node.getContext();
+
+        RubyProxyNode proxy;
+
+        if (node instanceof RubyProxyNode) {
+            proxy = (RubyProxyNode) node;
+        } else {
+            proxy = new RubyProxyNode(node.getContext(), node);
+            proxy.markAs(NodePhylum.STATEMENT);
+            proxy.clearSourceSection();
+            proxy.assignSourceSection(node.getSourceSection());
+        }
+
+        if (context.getConfiguration().getDebug()) {
+            final MethodLocal methodLocal = new MethodLocal(methodIdentifier, localName);
+            proxy.getProbeChain().appendProbe(new InactiveLocalDebugProbe(context, methodLocal, context.getRubyDebugManager().getAssumption(methodLocal)));
+        }
+
+        return proxy;
     }
 
 }