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

Commits on Jan 6, 2016

  1. [Truffle] When you have a rest and then a post in restructure, the re…

    …st should't capture what does into the post.
    chrisseaton committed Jan 6, 2016
    Copy the full SHA
    6397963 View commit details
  2. Copy the full SHA
    a39aad7 View commit details
9 changes: 0 additions & 9 deletions spec/truffle/tags/language/variables_tags.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
fails:Multiple assignment with a single RHS value calls #to_ary to convert an Object RHS
fails:Multiple assignment with a single RHS value calls #to_ary to convert an Object RHS with MLHS
fails:Multiple assignment with a single RHS value does not mutate a RHS Array
fails:Multiple assignment with a single RHS value raises a TypeError if #to_ary does not return an Array
fails:Multiple assignment with a single splatted RHS value calls #to_a to convert an Object RHS with MLHS
fails:Multiple assignment with a single splatted RHS value calls #to_a to convert nil to an empty Array
fails:Multiple assignment with a single splatted RHS value does not mutate a RHS Array
fails:Multiple assignment with a MRHS value calls #to_a to convert a splatted Object value in a MRHS
fails:Multiple assignment with a MRHS value calls #to_ary to convert a splatted Object when the position receiving the value is a multiple assignment
fails:Multiple assignment with a MRHS value does not call #to_ary to convert a splatted Object when the position receiving the value is a simple variable
fails:Multiple assignment with a MRHS value does not call #to_ary to convert an Object when the position receiving the value is a rest variable
fails:Multiple assignment with a MRHS value raises a TypeError if #to_ary does not return an Array
fails:Multiple assignment with a RHS assignment value does not mutate a RHS Array
Original file line number Diff line number Diff line change
@@ -1982,6 +1982,10 @@ public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {

// TODO CS 5-Jan-15 we shouldn't be doing this kind of low level optimisation or pattern matching - EA should do it for us

if (sourceSection.getSource().getName().endsWith("test.rb")) {
rhsTranslated = rhsTranslated;
}

if (preArray != null
&& node.getPost() == null
&& node.getRest() == null
@@ -2093,11 +2097,44 @@ public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {
}

if (node.getRest() != null) {
final ArrayGetTailNode assignedValue = ArrayGetTailNodeGen.create(context, sourceSection, preArray.size(), environment.findLocalVarNode(tempName, sourceSection));
RubyNode assignedValue = ArrayGetTailNodeGen.create(context, sourceSection, preArray.size(), environment.findLocalVarNode(tempName, sourceSection));

if (postArray != null) {
assignedValue = ArrayDropTailNodeGen.create(context, sourceSection, postArray.size(), assignedValue);
}

sequence.add(translateDummyAssignment(node.getRest(), assignedValue));
}

if (postArray != null) {
final List<RubyNode> smallerSequence = new ArrayList<>();

for (int n = 0; n < postArray.size(); n++) {
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(context, sourceSection, environment.findLocalVarNode(tempName, sourceSection), node.getPreCount() + n);
smallerSequence.add(translateDummyAssignment(postArray.get(n), assignedValue));
}

final RubyNode smaller = SequenceNode.sequence(context, sourceSection, smallerSequence);

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

for (int n = 0; n < postArray.size(); n++) {
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(context, sourceSection, environment.findLocalVarNode(tempName, sourceSection), -(postArray.size() - n));

atLeastAsLargeSequence.add(translateDummyAssignment(postArray.get(n), assignedValue));
}

final RubyNode atLeastAsLarge = SequenceNode.sequence(context, sourceSection, atLeastAsLargeSequence);

final RubyNode assignPost =
new IfNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, environment.findLocalVarNode(tempName, sourceSection), node.getPreCount() + node.getPostCount()),
atLeastAsLarge,
smaller);

sequence.add(assignPost);
}

result = new ElidableResultNode(context, sourceSection, SequenceNode.sequence(context, sourceSection, sequence), environment.findLocalVarNode(tempRHSName, sourceSection));
} else if (node.getPre() == null
&& node.getPost() == null
@@ -2127,7 +2164,7 @@ public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {
false, environment.findLocalVarNode(tempRHSName, sourceSection));

sequence.add(translateDummyAssignment(node.getRest(), rhsSplatCast));

result = new ElidableResultNode(context, sourceSection, SequenceNode.sequence(context, sourceSection, sequence), environment.findLocalVarNode(tempRHSName, sourceSection));
} else if (node.getPre() == null
&& node.getPost() == null
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ public static class BreakID {

private final String namedMethodName;

// TODO(CS): overflow?
// TODO(CS): overflow? and it should be per-context, or even more local
private static AtomicInteger tempIndex = new AtomicInteger();

public boolean hasRestParameter = false;