Skip to content

Commit

Permalink
[Truffle] Handle null SourceSection in WhileRepeatingBaseNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Oct 15, 2016
1 parent c9ca611 commit d3494fc
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -46,7 +46,7 @@ public Object execute(VirtualFrame frame) {
loopNode.executeLoop(frame);
return nil();
}

private static abstract class WhileRepeatingBaseNode extends Node implements RepeatingNode {

protected final RubyContext context;
Expand All @@ -67,7 +67,11 @@ public WhileRepeatingBaseNode(RubyContext context, RubyNode condition, RubyNode
@Override
public String toString() {
SourceSection sourceSection = getEncapsulatingSourceSection();
return String.format("while loop at %s:%d", sourceSection.getSource().getName(), sourceSection.getStartLine());
if (sourceSection != null && sourceSection.getSource() != null) {
return String.format("while loop at %s:%d", sourceSection.getSource().getName(), sourceSection.getStartLine());
} else {
return "while loop";
}
}

}
Expand Down Expand Up @@ -100,7 +104,7 @@ public boolean executeRepeating(VirtualFrame frame) {
}

}

private static class DoWhileRepeatingNode extends WhileRepeatingBaseNode implements RepeatingNode {

public DoWhileRepeatingNode(RubyContext context, RubyNode condition, RubyNode body) {
Expand Down

0 comments on commit d3494fc

Please sign in to comment.