Skip to content
Permalink
Browse files
[Truffle] Give DeadNodes a description and fix a case of them leaking…
… into a final AST.
  • Loading branch information
chrisseaton committed Jan 15, 2015
1 parent 07a515f commit ad62bc0074cfbcd389c67f81858cb5d6968bfb17
Showing with 10 additions and 7 deletions.
  1. +5 −5 core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  2. +5 −2 core/src/main/java/org/jruby/truffle/translator/DeadNode.java
@@ -1446,7 +1446,7 @@ public RubyNode visitInstAsgnNode(org.jruby.ast.InstAsgnNode node) {
RubyNode rhs;

if (node.getValueNode() == null) {
rhs = new DeadNode(context, sourceSection);
rhs = new DeadNode(context, sourceSection, "null RHS of instance variable assignment");
} else {
rhs = node.getValueNode().accept(this);
}
@@ -1538,7 +1538,7 @@ public RubyNode visitLocalAsgnNode(org.jruby.ast.LocalAsgnNode node) {
RubyNode rhs;

if (node.getValueNode() == null) {
rhs = new DeadNode(context, sourceSection);
rhs = new DeadNode(context, sourceSection, "null RHS of local variable assignment");
} else {
if (node.getValueNode().getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = sourceSection;
@@ -1998,7 +1998,7 @@ public RubyNode visitNextNode(org.jruby.ast.NextNode node) {
@Override
public RubyNode visitNilNode(org.jruby.ast.NilNode node) {
if (node.getPosition() == InvalidSourcePosition.INSTANCE && parentSourceSection == null) {
return new DeadNode(context, null);
return new DeadNode(context, null, "nil node with no invalid source position - assumed to be implicit null");
}

return new NilLiteralNode(context, translate(node.getPosition()));
@@ -2289,8 +2289,8 @@ public RubyNode visitRescueNode(org.jruby.ast.RescueNode node) {

RubyNode translatedBody;

if (rescueBody.getBodyNode() == null) {
translatedBody = new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject());
if (rescueBody.getBodyNode() == null || rescueBody.getBodyNode().getPosition() == InvalidSourcePosition.INSTANCE) {
translatedBody = new NilLiteralNode(context, sourceSection);
} else {
translatedBody = rescueBody.getBodyNode().accept(this);
}
@@ -20,12 +20,15 @@
*/
public class DeadNode extends RubyNode {

public DeadNode(RubyContext context, SourceSection sourceSection) {
private final String description;

public DeadNode(RubyContext context, SourceSection sourceSection, String description) {
super(context, sourceSection);
this.description = description;
}

@Override
public Object execute(VirtualFrame frame) {
throw new UnsupportedOperationException("Dead nodes should have been pruned before execution starts");
throw new UnsupportedOperationException("Dead nodes should have been pruned before execution starts: " + description);
}
}

0 comments on commit ad62bc0

Please sign in to comment.