Skip to content

Commit

Permalink
Showing 1 changed file with 10 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -2625,31 +2625,8 @@ public RubyNode visitUndefNode(org.jruby.ast.UndefNode node) {

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

RubyNode condition = node.getConditionNode().accept(this);
RubyNode conditionInversed = new NotNode(context, sourceSection, condition);

final boolean oldTranslatingWhile = translatingWhile;
translatingWhile = true;

final RubyNode body;

try {
body = node.getBodyNode().accept(this);
} finally {
translatingWhile = oldTranslatingWhile;
}

final RubyNode loop;

if (node.evaluateAtStart()) {
loop = WhileNode.createWhile(context, sourceSection, conditionInversed, body);
} else {
loop = WhileNode.createDoWhile(context, sourceSection, conditionInversed, body);
}

return new CatchBreakFromCallNode(context, sourceSection, loop, environment.getBlockID());
org.jruby.ast.WhileNode whileNode = new org.jruby.ast.WhileNode(node.getPosition(), node.getConditionNode(), node.getBodyNode(), node.evaluateAtStart());
return visitWhileNode(whileNode, true);
}

@Override
@@ -2666,23 +2643,27 @@ public RubyNode visitVCallNode(org.jruby.ast.VCallNode node) {

@Override
public RubyNode visitWhileNode(org.jruby.ast.WhileNode node) {
return visitWhileNode(node, false);
}

private RubyNode visitWhileNode(org.jruby.ast.WhileNode node, boolean conditionInversed) {
final SourceSection sourceSection = translate(node.getPosition());

RubyNode condition = node.getConditionNode().accept(this);
if (conditionInversed) {
condition = new NotNode(context, sourceSection, condition);
}

final RubyNode body;
final boolean oldTranslatingWhile = translatingWhile;
translatingWhile = true;

final RubyNode body;

try {
body = node.getBodyNode().accept(this);
} finally {
translatingWhile = oldTranslatingWhile;
}

final RubyNode loop;

if (node.evaluateAtStart()) {
loop = WhileNode.createWhile(context, sourceSection, condition, body);
} else {

0 comments on commit db0bd4e

Please sign in to comment.