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: 79c8359d5523
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c295c1e5685a
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 19, 2016

  1. Copy the full SHA
    1352604 View commit details
  2. Copy the full SHA
    c295c1e View commit details
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@
package org.jruby.truffle.language.control;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.cast.BooleanCastNode;
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.language.RubyNode;
@@ -20,8 +18,8 @@ public class NotNode extends RubyNode {

@Child private BooleanCastNode child;

public NotNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection);
public NotNode(RubyNode child) {
super(child.getContext(), child.getSourceSection());
this.child = BooleanCastNodeGen.create(child);
}

Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import org.jruby.ast.SideEffectFree;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.common.IRubyWarnings;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.lexer.yacc.InvalidSourcePosition;
import org.jruby.parser.ParserSupport;
import org.jruby.runtime.ArgumentDescriptor;
@@ -32,6 +33,7 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.PrimitiveNodeConstructor;
import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.IsNilNode;
import org.jruby.truffle.core.IsRubiniusUndefinedNode;
import org.jruby.truffle.core.RaiseIfFrozenNode;
import org.jruby.truffle.core.array.ArrayAppendOneNodeGen;
@@ -2406,18 +2408,20 @@ public RubyNode visitOpAsgnAndNode(org.jruby.ast.OpAsgnAndNode node) {

@Override
public RubyNode visitOpAsgnNode(org.jruby.ast.OpAsgnNode node) {
final ISourcePosition pos = node.getPosition();

if (node.getOperatorName().equals("||")) {
// Why does this ||= come through as a visitOpAsgnNode and not a visitOpAsgnOrNode?

final String temp = environment.allocateLocalTemp("opassign");
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 writeReceiverToTemp = new org.jruby.ast.LocalAsgnNode(pos, temp, 0, node.getReceiverNode());
final org.jruby.ast.Node readReceiverFromTemp = new org.jruby.ast.LocalVarNode(pos, 0, temp);

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(),
final org.jruby.ast.Node readMethod = new org.jruby.ast.CallNode(pos, readReceiverFromTemp, node.getVariableName(), null, null);
final org.jruby.ast.Node writeMethod = new org.jruby.ast.CallNode(pos, readReceiverFromTemp, node.getVariableName() + "=", buildArrayNode(pos,
node.getValueNode()), null);

final SourceSection sourceSection = translate(node.getPosition());
final SourceSection sourceSection = translate(pos);

RubyNode lhs = readMethod.accept(this);
RubyNode rhs = writeMethod.accept(this);
@@ -2436,19 +2440,32 @@ public RubyNode visitOpAsgnNode(org.jruby.ast.OpAsgnNode node) {
*/

final String temp = environment.allocateLocalTemp("opassign");
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 writeReceiverToTemp = new org.jruby.ast.LocalAsgnNode(pos, temp, 0, node.getReceiverNode());

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.Node readReceiverFromTemp = new org.jruby.ast.LocalVarNode(pos, 0, temp);

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

final org.jruby.ast.BlockNode block = new org.jruby.ast.BlockNode(pos);
block.add(writeReceiverToTemp);
block.add(writeMethod);

final RubyNode ret = block.accept(this);
final RubyNode writeTemp = writeReceiverToTemp.accept(this);
RubyNode body = writeMethod.accept(this);

final SourceSection sourceSection = body.getSourceSection();

if (node.isLazy()) {
ReadLocalNode readLocal = environment.findLocalVarNode(temp, sourceSection);
body = new IfNode(context, sourceSection,
new NotNode(new IsNilNode(context, sourceSection, readLocal)),
body);
}
final RubyNode ret = sequence(context, sourceSection, Arrays.asList(writeTemp, body));

return addNewlineIfNeeded(node, ret);
}

@@ -2891,7 +2908,7 @@ private RubyNode translateWhileNode(org.jruby.ast.WhileNode node, boolean condit

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

RubyNode body;
Original file line number Diff line number Diff line change
@@ -55,7 +55,6 @@
import org.jruby.truffle.language.supercall.ReadZSuperArgumentsNode;
import org.jruby.truffle.language.supercall.SuperCallNode;
import org.jruby.truffle.language.supercall.ZSuperOutsideMethodNode;

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
@@ -107,7 +106,8 @@ public BlockDefinitionNode compileBlockNode(SourceSection sourceSection, String

final RubyNode shouldDestructure = new ShouldDestructureNode(readArrayNode);

final RubyNode arrayWasNotNil = sequence(context, sourceSection, Arrays.asList(writeArrayNode, new NotNode(context, sourceSection, new IsNilNode(context, sourceSection, new ReadLocalVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, arraySlot)))));
final RubyNode arrayWasNotNil = sequence(context, sourceSection,
Arrays.asList(writeArrayNode, new NotNode(new IsNilNode(context, sourceSection, new ReadLocalVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, arraySlot)))));

final RubyNode shouldDestructureAndArrayWasNotNil = new AndNode(context, sourceSection,
shouldDestructure,