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

Commits on Jan 3, 2016

  1. Copy the full SHA
    c555813 View commit details
  2. Copy the full SHA
    6e71a2e View commit details
1 change: 0 additions & 1 deletion spec/truffle/tags/language/send_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.arguments;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;

public class ArrayIsAtLeastAsLargeAsNode extends RubyNode {

@Child private RubyNode child;

private final int requiredSize;

public ArrayIsAtLeastAsLargeAsNode(RubyContext context, SourceSection sourceSection, RubyNode child, int requiredSize) {
super(context, sourceSection);
this.child = child;
this.requiredSize = requiredSize;
}

@Override
public boolean executeBoolean(VirtualFrame frame) {
return Layouts.ARRAY.getSize((DynamicObject) child.execute(frame)) >= requiredSize;
}

@Override
public Object execute(VirtualFrame frame) {
return executeBoolean(frame);
}

}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.joni.NameEntry;
import org.joni.Regex;
import org.joni.Syntax;
import org.jruby.ast.StarNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.common.IRubyWarnings;
import org.jruby.lexer.yacc.InvalidSourcePosition;
@@ -2776,6 +2777,11 @@ public RubyNode visitBackRefNode(org.jruby.ast.BackRefNode node) {
return addNewlineIfNeeded(node, ret);
}

@Override
public RubyNode visitStarNode(org.jruby.ast.StarNode star) {
return nilNode(translate(star.getPosition()));
}

protected RubyNode initFlipFlopStates(SourceSection sourceSection) {
final RubyNode[] initNodes = new RubyNode[environment.getFlipFlopStates().size()];

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
@@ -339,34 +339,74 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnNode node) {
childNodes = node.childNodes().get(0).childNodes();
}

final List<RubyNode> notNilSequence = new ArrayList<>();
// The load to use when the array is not nil and the length is smaller than the number of required arguments

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

if (node.getPre() != null) {
index = 0;
for (org.jruby.ast.Node child : node.getPre().children()) {
notNilSmallerSequence.add(child.accept(this));
index++;
}
}

if (node.getRest() != null) {
index = node.getPreCount();
indexFromEnd = -node.getPostCount();
notNilSmallerSequence.add(node.getRest().accept(this));
indexFromEnd = 1;
}

if (node.getPost() != null) {
org.jruby.ast.Node[] children = node.getPost().children();
index = node.getPreCount();
for (int i = 0; i < children.length; i++) {
notNilSmallerSequence.add(children[i].accept(this));
index++;
}
}

final RubyNode notNilSmaller = SequenceNode.sequence(context, sourceSection, notNilSmallerSequence);

if (notNilSmaller == null) {
throw new UnsupportedOperationException();
}

// The load to use when the array is not nil and at least as large as the number of required arguments

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

if (node.getPre() != null) {
index = 0;
for (org.jruby.ast.Node child : node.getPre().children()) {
notNilSequence.add(child.accept(this));
notNilAtLeastAsLargeSequence.add(child.accept(this));
index++;
}
}

if (node.getRest() != null) {
index = node.getPreCount();
indexFromEnd = -node.getPostCount();
notNilSequence.add(node.getRest().accept(this));
notNilAtLeastAsLargeSequence.add(node.getRest().accept(this));
indexFromEnd = 1;
}

if (node.getPost() != null) {
org.jruby.ast.Node[] children = node.getPost().children();
index = -1;
for (int i = children.length - 1; i >= 0; i--) {
notNilSequence.add(children[i].accept(this));
notNilAtLeastAsLargeSequence.add(children[i].accept(this));
required++;
index--;
}
}

final RubyNode notNil = SequenceNode.sequence(context, sourceSection, notNilSequence);
final RubyNode notNilAtLeastAsLarge = SequenceNode.sequence(context, sourceSection, notNilAtLeastAsLargeSequence);

if (notNilAtLeastAsLarge == null) {
throw new UnsupportedOperationException();
}

popArraySlot(arraySlot);

@@ -417,7 +457,10 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnNode node) {
new IfNode(context, sourceSection,
new IsNilNode(context, sourceSection, new ReadLocalVariableNode(context, sourceSection, arraySlot)),
nil,
notNil == null ? nilNode(sourceSection) : notNil));
new IfNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, new ReadLocalVariableNode(context, sourceSection, arraySlot), node.getPreCount() + node.getPostCount()),
notNilAtLeastAsLarge,
notNilSmaller)));
}

@Override