Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7905705eee06
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e19a173deb08
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Nov 23, 2015

  1. [Truffle] Made the distinction between Truffle nodes and JRuby nodes …

    …very clear in the translator.
    chrisseaton committed Nov 23, 2015
    Copy the full SHA
    ae20878 View commit details
  2. Copy the full SHA
    e19a173 View commit details
Showing with 71 additions and 58 deletions.
  1. +71 −58 truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
129 changes: 71 additions & 58 deletions truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@
import org.joni.NameEntry;
import org.joni.Regex;
import org.joni.Syntax;
import org.jruby.ast.*;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.common.IRubyWarnings;
import org.jruby.lexer.yacc.InvalidSourcePosition;
@@ -46,7 +45,6 @@
import org.jruby.truffle.nodes.control.ReturnNode;
import org.jruby.truffle.nodes.control.WhileNode;
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.core.ModuleNodes.UndefMethodNode;
import org.jruby.truffle.nodes.core.ModuleNodesFactory.AliasMethodNodeFactory;
import org.jruby.truffle.nodes.core.ModuleNodesFactory.UndefMethodNodeFactory;
import org.jruby.truffle.nodes.core.ProcNodes.Type;
@@ -87,7 +85,6 @@
import org.jruby.truffle.translator.TranslatorEnvironment.BreakID;
import org.jruby.util.ByteList;
import org.jruby.util.KeyValuePair;
import org.jruby.util.StringSupport;

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
@@ -196,7 +193,7 @@ private void collectArgsCatNodes(List<org.jruby.ast.Node> nodes, org.jruby.ast.A
collectArgsCatNodes(nodes, (org.jruby.ast.ArgsCatNode) node.getSecondNode());
} else {
// ArgsCatNode implicitly splat its second argument. See Helpers.argsCat.
Node secondNode = new SplatNode(node.getSecondNode().getPosition(), node.getSecondNode());
org.jruby.ast.Node secondNode = new org.jruby.ast.SplatNode(node.getSecondNode().getPosition(), node.getSecondNode());
nodes.add(secondNode);
}
}
@@ -285,7 +282,8 @@ public RubyNode visitAttrAssignNode(org.jruby.ast.AttrAssignNode node) {
fixedArgsNode = newArgsNode;
}

final CallNode callNode = new CallNode(node.getPosition(), node.getReceiverNode(), node.getName(), fixedArgsNode, null);
final org.jruby.ast.CallNode callNode = new org.jruby.ast.CallNode(node.getPosition(), node.getReceiverNode(), node.getName(), fixedArgsNode, null);
copyNewline(node, callNode);
boolean isAccessorOnSelf = (node.getReceiverNode() instanceof org.jruby.ast.SelfNode);
final RubyNode actualCall = translateCallNode(callNode, isAccessorOnSelf, false);

@@ -383,14 +381,14 @@ public RubyNode visitBreakNode(org.jruby.ast.BreakNode node) {
}

@Override
public RubyNode visitCallNode(CallNode node) {
public RubyNode visitCallNode(org.jruby.ast.CallNode node) {
final SourceSection sourceSection = translate(node.getPosition());
final Node receiver = node.getReceiverNode();
final org.jruby.ast.Node receiver = node.getReceiverNode();
final String methodName = node.getName();

// Rubinius.<method>
if (receiver instanceof org.jruby.ast.ConstNode
&& ((ConstNode) receiver).getName().equals("Rubinius")) {
&& ((org.jruby.ast.ConstNode) receiver).getName().equals("Rubinius")) {
if (methodName.equals("primitive")) {
final RubyNode ret = translateRubiniusPrimitive(sourceSection, node);
return addNewlineIfNeeded(node, ret);
@@ -419,15 +417,15 @@ public RubyNode visitCallNode(CallNode node) {
return addNewlineIfNeeded(node, ret);
}
} else if (receiver instanceof org.jruby.ast.ConstNode // Truffle.omit
&& ((ConstNode) receiver).getName().equals("Truffle")) {
&& ((org.jruby.ast.ConstNode) receiver).getName().equals("Truffle")) {
if (methodName.equals("omit")) {
// We're never going to run the omitted code and it's never used as the RHS for anything, so just
// replace the call with nil.
final RubyNode ret = nilNode(sourceSection);
return addNewlineIfNeeded(node, ret);
}
} else if (receiver instanceof VCallNode // undefined.equal?(obj)
&& ((VCallNode) receiver).getName().equals("undefined")
} else if (receiver instanceof org.jruby.ast.VCallNode // undefined.equal?(obj)
&& ((org.jruby.ast.VCallNode) receiver).getName().equals("undefined")
&& sourceSection.getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")
&& methodName.equals("equal?")) {
RubyNode argument = translateArgumentsAndBlock(sourceSection, null, node.getArgsNode(), methodName).getArguments()[0];
@@ -438,7 +436,7 @@ public RubyNode visitCallNode(CallNode node) {
return translateCallNode(node, false, false);
}

private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, CallNode node) {
private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, org.jruby.ast.CallNode node) {
usesRubiniusPrimitive = true;

/*
@@ -470,7 +468,7 @@ private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, CallNod
return primitive.createCallPrimitiveNode(context, sourceSection, returnID);
}

private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, CallNode node) {
private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, org.jruby.ast.CallNode node) {
/*
* Translates something that looks like
*
@@ -504,7 +502,7 @@ private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, C
return primitive.createInvokePrimitiveNode(context, sourceSection, arguments.toArray(new RubyNode[arguments.size()]));
}

private RubyNode translateRubiniusPrivately(SourceSection sourceSection, CallNode node) {
private RubyNode translateRubiniusPrivately(SourceSection sourceSection, org.jruby.ast.CallNode node) {
/*
* Translates something that looks like
*
@@ -550,15 +548,15 @@ private RubyNode translateRubiniusPrivately(SourceSection sourceSection, CallNod
}
}

public RubyNode translateRubiniusSingleBlockArg(SourceSection sourceSection, CallNode node) {
public RubyNode translateRubiniusSingleBlockArg(SourceSection sourceSection, org.jruby.ast.CallNode node) {
return new RubiniusSingleBlockArgNode(context, sourceSection);
}

private RubyNode translateRubiniusCheckFrozen(SourceSection sourceSection) {
return new RaiseIfFrozenNode(new SelfNode(context, sourceSection));
}

private RubyNode translateCallNode(CallNode node, boolean ignoreVisibility, boolean isVCall) {
private RubyNode translateCallNode(org.jruby.ast.CallNode node, boolean ignoreVisibility, boolean isVCall) {
final SourceSection sourceSection = translate(node.getPosition());

final RubyNode receiverTranslated = node.getReceiverNode().accept(this);
@@ -801,7 +799,7 @@ public RubyNode visitCaseNode(org.jruby.ast.CaseNode node) {
return addNewlineIfNeeded(node, ret);
}

private RubyNode openModule(SourceSection sourceSection, RubyNode defineOrGetNode, String name, Node bodyNode) {
private RubyNode openModule(SourceSection sourceSection, RubyNode defineOrGetNode, String name, org.jruby.ast.Node bodyNode) {
LexicalScope newLexicalScope = environment.pushLexicalScope();
try {
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, newLexicalScope, Arity.NO_ARGUMENTS, name, false, null, false, false, false);
@@ -891,7 +889,7 @@ public RubyNode visitClassVarNode(org.jruby.ast.ClassVarNode node) {
@Override
public RubyNode visitColon2Node(org.jruby.ast.Colon2Node node) {
// Qualified constant access, as in Mod::CONST
if (!(node instanceof Colon2ConstNode)) {
if (!(node instanceof org.jruby.ast.Colon2ConstNode)) {
throw new UnsupportedOperationException(node.toString());
}

@@ -920,9 +918,9 @@ public RubyNode visitColon3Node(org.jruby.ast.Colon3Node node) {
private RubyNode translateCPath(SourceSection sourceSection, org.jruby.ast.Colon3Node node) {
final RubyNode ret;

if (node instanceof Colon2ImplicitNode) { // use current lexical scope
if (node instanceof org.jruby.ast.Colon2ImplicitNode) { // use current lexical scope
ret = new LexicalScopeNode(context, sourceSection, environment.getLexicalScope());
} else if (node instanceof Colon2ConstNode) { // A::B
} else if (node instanceof org.jruby.ast.Colon2ConstNode) { // A::B
ret = node.childNodes().get(0).accept(this);
} else { // Colon3Node: on top-level (Object)
ret = new LiteralNode(context, sourceSection, context.getCoreLibrary().getObjectClass());
@@ -932,7 +930,7 @@ private RubyNode translateCPath(SourceSection sourceSection, org.jruby.ast.Colon
}

@Override
public RubyNode visitComplexNode(ComplexNode node) {
public RubyNode visitComplexNode(org.jruby.ast.ComplexNode node) {
final SourceSection sourceSection = translate(node.getPosition());

final RubyNode ret = translateRationalComplex(sourceSection, "Complex",
@@ -948,13 +946,13 @@ public RubyNode visitConstDeclNode(org.jruby.ast.ConstDeclNode node) {
RubyNode rhs = node.getValueNode().accept(this);

final RubyNode moduleNode;
Node constNode = node.getConstNode();
if (constNode == null || constNode instanceof Colon2ImplicitNode) {
org.jruby.ast.Node constNode = node.getConstNode();
if (constNode == null || constNode instanceof org.jruby.ast.Colon2ImplicitNode) {
moduleNode = new LexicalScopeNode(context, sourceSection, environment.getLexicalScope());
} else if (constNode instanceof Colon2ConstNode) {
constNode = ((Colon2Node) constNode).getLeftNode(); // Misleading doc, we only want the defined part.
} else if (constNode instanceof org.jruby.ast.Colon2ConstNode) {
constNode = ((org.jruby.ast.Colon2Node) constNode).getLeftNode(); // Misleading doc, we only want the defined part.
moduleNode = constNode.accept(this);
} else if (constNode instanceof Colon3Node) {
} else if (constNode instanceof org.jruby.ast.Colon3Node) {
moduleNode = new LiteralNode(context, sourceSection, context.getCoreLibrary().getObjectClass());
} else {
throw new UnsupportedOperationException();
@@ -1072,7 +1070,8 @@ public RubyNode visitDXStrNode(org.jruby.ast.DXStrNode node) {
final org.jruby.ast.DStrNode string = new org.jruby.ast.DStrNode(node.getPosition(), node.getEncoding());
string.addAll(node);
final org.jruby.ast.Node argsNode = buildArrayNode(node.getPosition(), string);
final org.jruby.ast.Node callNode = new FCallNode(node.getPosition(), "`", argsNode, null);
final org.jruby.ast.Node callNode = new org.jruby.ast.FCallNode(node.getPosition(), "`", argsNode, null);
copyNewline(node, callNode);
final RubyNode ret = callNode.accept(this);
return addNewlineIfNeeded(node, ret);
}
@@ -1198,8 +1197,8 @@ public RubyNode visitEvStrNode(org.jruby.ast.EvStrNode node) {
@Override
public RubyNode visitFCallNode(org.jruby.ast.FCallNode node) {
final org.jruby.ast.Node receiver = new org.jruby.ast.SelfNode(node.getPosition());
final CallNode callNode = new CallNode(node.getPosition(), receiver, node.getName(), node.getArgsNode(), node.getIterNode());

final org.jruby.ast.CallNode callNode = new org.jruby.ast.CallNode(node.getPosition(), receiver, node.getName(), node.getArgsNode(), node.getIterNode());
copyNewline(node, callNode);
return translateCallNode(callNode, true, false);
}

@@ -1346,7 +1345,8 @@ public RubyNode visitForNode(org.jruby.ast.ForNode node) {
final org.jruby.ast.ArgsNode blockArgs = new org.jruby.ast.ArgsNode(node.getPosition(), blockArgsPre, null, null, null, null, null, null);
final org.jruby.ast.IterNode block = new org.jruby.ast.IterNode(node.getPosition(), blockArgs, node.getScope(), bodyWithTempAssign);

final CallNode callNode = new CallNode(node.getPosition(), receiver, "each", null, block);
final org.jruby.ast.CallNode callNode = new org.jruby.ast.CallNode(node.getPosition(), receiver, "each", null, block);
copyNewline(node, callNode);

translatingForStatement = true;
final RubyNode translated = callNode.accept(this);
@@ -1358,7 +1358,7 @@ public RubyNode visitForNode(org.jruby.ast.ForNode node) {
private static final ParserSupport PARSER_SUPPORT = new ParserSupport();

private static org.jruby.ast.Node setRHS(org.jruby.ast.Node node, org.jruby.ast.Node rhs) {
if (node instanceof AssignableNode || node instanceof IArgumentNode) {
if (node instanceof org.jruby.ast.AssignableNode || node instanceof org.jruby.ast.IArgumentNode) {
return PARSER_SUPPORT.node_assign(node, rhs);
} else {
throw new UnsupportedOperationException("Don't know how to set the RHS of a " + node.getClass().getName());
@@ -1372,7 +1372,7 @@ private RubyNode translateDummyAssignment(org.jruby.ast.Node dummyAssignment, fi
if (dummyAssignment instanceof org.jruby.ast.StarNode) {
// Nothing to assign to, just execute the RHS
return rhs;
} else if (dummyAssignment instanceof AssignableNode || dummyAssignment instanceof IArgumentNode) {
} else if (dummyAssignment instanceof org.jruby.ast.AssignableNode || dummyAssignment instanceof org.jruby.ast.IArgumentNode) {
final org.jruby.ast.Node wrappedRHS = new org.jruby.ast.Node(dummyAssignment.getPosition(), false) {
@SuppressWarnings("unchecked")
@Override
@@ -1381,13 +1381,13 @@ public <T> T accept(NodeVisitor<T> visitor) {
}

@Override
public List<Node> childNodes() {
public List<org.jruby.ast.Node> childNodes() {
return Collections.emptyList();
}

@Override
public NodeType getNodeType() {
return NodeType.FIXNUMNODE; // since we behave like a value
public org.jruby.ast.NodeType getNodeType() {
return org.jruby.ast.NodeType.FIXNUMNODE; // since we behave like a value
}
};

@@ -1526,7 +1526,7 @@ public RubyNode visitHashNode(org.jruby.ast.HashNode node) {

final List<RubyNode> keyValues = new ArrayList<>();

for (KeyValuePair<Node, Node> pair: node.getPairs()) {
for (KeyValuePair<org.jruby.ast.Node, org.jruby.ast.Node> pair: node.getPairs()) {
if (pair.getKey() == null) {
final RubyNode hashLiteralSoFar = HashLiteralNode.create(context, translate(node.getPosition()), keyValues.toArray(new RubyNode[keyValues.size()]));
hashConcats.add(hashLiteralSoFar);
@@ -1760,7 +1760,7 @@ public RubyNode visitIterNode(org.jruby.ast.IterNode node) {
}

// Unset this flag for any for any blocks within the for statement's body
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), currentCallMethodName, true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(ArgsNode.class)), false, false, false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), currentCallMethodName, true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(org.jruby.ast.ArgsNode.class)), false, false, false);

final TranslatorEnvironment newEnvironment = new TranslatorEnvironment(
context, environment, environment.getParseEnvironment(), environment.getReturnID(), hasOwnScope, false,
@@ -1856,7 +1856,8 @@ public RubyNode visitMatchNode(org.jruby.ast.MatchNode node) {
// Triggered when a Regexp literal is used as a conditional's value.

final org.jruby.ast.Node argsNode = buildArrayNode(node.getPosition(), new org.jruby.ast.GlobalVarNode(node.getPosition(), "$_"));
final org.jruby.ast.Node callNode = new CallNode(node.getPosition(), node.getRegexpNode(), "=~", argsNode, null);
final org.jruby.ast.Node callNode = new org.jruby.ast.CallNode(node.getPosition(), node.getRegexpNode(), "=~", argsNode, null);
copyNewline(node, callNode);
final RubyNode ret = callNode.accept(this);
return addNewlineIfNeeded(node, ret);
}
@@ -1890,7 +1891,8 @@ public RubyNode visitMatch2Node(org.jruby.ast.Match2Node node) {
}

final org.jruby.ast.Node argsNode = buildArrayNode(node.getPosition(), node.getValueNode());
final org.jruby.ast.Node callNode = new CallNode(node.getPosition(), node.getReceiverNode(), "=~", argsNode, null);
final org.jruby.ast.Node callNode = new org.jruby.ast.CallNode(node.getPosition(), node.getReceiverNode(), "=~", argsNode, null);
copyNewline(node, callNode);
final RubyNode ret = callNode.accept(this);
return addNewlineIfNeeded(node, ret);
}
@@ -1900,7 +1902,8 @@ public RubyNode visitMatch3Node(org.jruby.ast.Match3Node node) {
// Triggered when a Regexp literal is the RHS of an expression.

final org.jruby.ast.Node argsNode = buildArrayNode(node.getPosition(), node.getValueNode());
final org.jruby.ast.Node callNode = new CallNode(node.getPosition(), node.getReceiverNode(), "=~", argsNode, null);
final org.jruby.ast.Node callNode = new org.jruby.ast.CallNode(node.getPosition(), node.getReceiverNode(), "=~", argsNode, null);
copyNewline(node, callNode);
final RubyNode ret = callNode.accept(this);
return addNewlineIfNeeded(node, ret);
}
@@ -1920,7 +1923,7 @@ public RubyNode visitModuleNode(org.jruby.ast.ModuleNode node) {
}

@Override
public RubyNode visitMultipleAsgnNode(MultipleAsgnNode node) {
public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {
final SourceSection sourceSection = translate(node.getPosition());

final org.jruby.ast.ListNode preArray = node.getPre();
@@ -2253,8 +2256,8 @@ public RubyNode visitOpAsgnNode(org.jruby.ast.OpAsgnNode node) {
final org.jruby.ast.Node writeReceiverToTemp = new org.jruby.ast.LocalAsgnNode(node.getPosition(), temp, 0, node.getReceiverNode());
final org.jruby.ast.Node readReceiverFromTemp = new org.jruby.ast.LocalVarNode(node.getPosition(), 0, temp);

final org.jruby.ast.Node readMethod = new CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName(), null, null);
final org.jruby.ast.Node writeMethod = new CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName() + "=", buildArrayNode(node.getPosition(),
final org.jruby.ast.Node readMethod = new org.jruby.ast.CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName(), null, null);
final org.jruby.ast.Node writeMethod = new org.jruby.ast.CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName() + "=", buildArrayNode(node.getPosition(),
node.getValueNode()), null);

final SourceSection sourceSection = translate(node.getPosition());
@@ -2280,9 +2283,9 @@ public RubyNode visitOpAsgnNode(org.jruby.ast.OpAsgnNode node) {
final org.jruby.ast.Node writeReceiverToTemp = new org.jruby.ast.LocalAsgnNode(node.getPosition(), temp, 0, node.getReceiverNode());
final org.jruby.ast.Node readReceiverFromTemp = new org.jruby.ast.LocalVarNode(node.getPosition(), 0, temp);

final org.jruby.ast.Node readMethod = new CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName(), null, null);
final org.jruby.ast.Node operation = new CallNode(node.getPosition(), readMethod, node.getOperatorName(), buildArrayNode(node.getPosition(), node.getValueNode()), null);
final org.jruby.ast.Node writeMethod = new CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName() + "=", buildArrayNode(node.getPosition(),
final org.jruby.ast.Node readMethod = new org.jruby.ast.CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName(), null, null);
final org.jruby.ast.Node operation = new org.jruby.ast.CallNode(node.getPosition(), readMethod, node.getOperatorName(), buildArrayNode(node.getPosition(), node.getValueNode()), null);
final org.jruby.ast.Node writeMethod = new org.jruby.ast.CallNode(node.getPosition(), readReceiverFromTemp, node.getVariableName() + "=", buildArrayNode(node.getPosition(),
operation), null);

final org.jruby.ast.BlockNode block = new org.jruby.ast.BlockNode(node.getPosition());
@@ -2341,7 +2344,7 @@ public RubyNode visitOpElementAsgnNode(org.jruby.ast.OpElementAsgnNode node) {
final org.jruby.ast.Node writeArrayToTemp = new org.jruby.ast.LocalAsgnNode(node.getPosition(), temp, 0, node.getReceiverNode());
final org.jruby.ast.Node readArrayFromTemp = new org.jruby.ast.LocalVarNode(node.getPosition(), 0, temp);

final org.jruby.ast.Node arrayRead = new CallNode(node.getPosition(), readArrayFromTemp, "[]", buildArrayNode(node.getPosition(), index), null);
final org.jruby.ast.Node arrayRead = new org.jruby.ast.CallNode(node.getPosition(), readArrayFromTemp, "[]", buildArrayNode(node.getPosition(), index), null);

final String op = node.getOperatorName();

@@ -2352,10 +2355,12 @@ public RubyNode visitOpElementAsgnNode(org.jruby.ast.OpElementAsgnNode node) {
} else if (op.equals("&&")) {
operation = new org.jruby.ast.AndNode(node.getPosition(), arrayRead, operand);
} else {
operation = new CallNode(node.getPosition(), arrayRead, node.getOperatorName(), buildArrayNode(node.getPosition(), operand), null);
operation = new org.jruby.ast.CallNode(node.getPosition(), arrayRead, node.getOperatorName(), buildArrayNode(node.getPosition(), operand), null);
}

final org.jruby.ast.Node arrayWrite = new CallNode(node.getPosition(), readArrayFromTemp, "[]=", buildArrayNode(node.getPosition(), index, operation), null);
copyNewline(node, operation);

final org.jruby.ast.Node arrayWrite = new org.jruby.ast.CallNode(node.getPosition(), readArrayFromTemp, "[]=", buildArrayNode(node.getPosition(), index, operation), null);

final org.jruby.ast.BlockNode block = new org.jruby.ast.BlockNode(node.getPosition());
block.add(writeArrayToTemp);
@@ -2391,19 +2396,19 @@ public RubyNode visitOrNode(org.jruby.ast.OrNode node) {
}

@Override
public RubyNode visitPreExeNode(PreExeNode node) {
public RubyNode visitPreExeNode(org.jruby.ast.PreExeNode node) {
final RubyNode ret = node.getBodyNode().accept(this);
return addNewlineIfNeeded(node, ret);
}

@Override
public RubyNode visitPostExeNode(PostExeNode node) {
public RubyNode visitPostExeNode(org.jruby.ast.PostExeNode node) {
final RubyNode ret = node.getBodyNode().accept(this);
return addNewlineIfNeeded(node, ret);
}

@Override
public RubyNode visitRationalNode(RationalNode node) {
public RubyNode visitRationalNode(org.jruby.ast.RationalNode node) {
final SourceSection sourceSection = translate(node.getPosition());

// TODO(CS): use IntFixnumLiteralNode where possible
@@ -2657,6 +2662,7 @@ public RubyNode visitUndefNode(org.jruby.ast.UndefNode node) {
@Override
public RubyNode visitUntilNode(org.jruby.ast.UntilNode node) {
org.jruby.ast.WhileNode whileNode = new org.jruby.ast.WhileNode(node.getPosition(), node.getConditionNode(), node.getBodyNode(), node.evaluateAtStart());
copyNewline(node, whileNode);
final RubyNode ret = translateWhileNode(whileNode, true);
return addNewlineIfNeeded(node, ret);
}
@@ -2670,7 +2676,8 @@ public RubyNode visitVCallNode(org.jruby.ast.VCallNode node) {
}

final org.jruby.ast.Node receiver = new org.jruby.ast.SelfNode(node.getPosition());
final CallNode callNode = new CallNode(node.getPosition(), receiver, node.getName(), null, null);
final org.jruby.ast.CallNode callNode = new org.jruby.ast.CallNode(node.getPosition(), receiver, node.getName(), null, null);
copyNewline(node, callNode);
final RubyNode ret = translateCallNode(callNode, true, true);
return addNewlineIfNeeded(node, ret);
}
@@ -2718,7 +2725,7 @@ private RubyNode translateWhileNode(org.jruby.ast.WhileNode node, boolean condit
@Override
public RubyNode visitXStrNode(org.jruby.ast.XStrNode node) {
final org.jruby.ast.Node argsNode = buildArrayNode(node.getPosition(), new org.jruby.ast.StrNode(node.getPosition(), node.getValue()));
final org.jruby.ast.Node callNode = new FCallNode(node.getPosition(), "`", argsNode, null);
final org.jruby.ast.Node callNode = new org.jruby.ast.FCallNode(node.getPosition(), "`", argsNode, null);
final RubyNode ret = callNode.accept(this);
return addNewlineIfNeeded(node, ret);
}
@@ -2806,7 +2813,7 @@ public RubyNode visitLambdaNode(org.jruby.ast.LambdaNode node) {
}

// TODO(cs): code copied and modified from visitIterNode - extract common
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), "(lambda)", true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(ArgsNode.class)), false, false, false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), "(lambda)", true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(org.jruby.ast.ArgsNode.class)), false, false, false);

final TranslatorEnvironment newEnvironment = new TranslatorEnvironment(
context, environment, environment.getParseEnvironment(), environment.getReturnID(), false, false,
@@ -2829,12 +2836,12 @@ protected RubyNode initFlipFlopStates(SourceSection sourceSection) {
}

@Override
protected RubyNode defaultVisit(Node node) {
protected RubyNode defaultVisit(org.jruby.ast.Node node) {
final RubyNode ret = unimplemented(node);
return addNewlineIfNeeded(node, ret);
}

protected RubyNode unimplemented(Node node) {
protected RubyNode unimplemented(org.jruby.ast.Node node) {
context.getRuntime().getWarnings().warn(IRubyWarnings.ID.TRUFFLE, source.getName(), node.getPosition().getLine(), node + " does nothing - translating as nil");
SourceSection sourceSection = translate(node.getPosition());
return nilNode(sourceSection);
@@ -2860,7 +2867,7 @@ protected String getIdentifier() {
}

@Override
public RubyNode visitOther(Node node) {
public RubyNode visitOther(org.jruby.ast.Node node) {
if (node instanceof ReadLocalDummyNode) {
final ReadLocalDummyNode readLocal = (ReadLocalDummyNode) node;
final RubyNode ret = new ReadLocalVariableNode(context, readLocal.getSourceSection(), readLocal.getFrameSlot());
@@ -2870,6 +2877,12 @@ public RubyNode visitOther(Node node) {
}
}

private void copyNewline(org.jruby.ast.Node from, org.jruby.ast.Node to) {
if (from.isNewline()) {
to.setNewline();
}
}

private RubyNode addNewlineIfNeeded(org.jruby.ast.Node jrubyNode, RubyNode node) {
if (jrubyNode.isNewline()) {
node.setAtNewline();