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

Commits on Mar 11, 2015

  1. Copy the full SHA
    e492774 View commit details
  2. Merge pull request #2685 from bjfish/truffle_array_at

    [Truffle] Adding #to_int to Array#at paramters.
    nirvdrum committed Mar 11, 2015
    Copy the full SHA
    06be1c0 View commit details
1 change: 0 additions & 1 deletion spec/truffle/tags/core/array/at_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/array/sample_tags.txt

This file was deleted.

15 changes: 13 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -21,12 +21,15 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;

import org.jruby.RubyObject;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.nodes.CoreSourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.array.*;
import org.jruby.truffle.nodes.coerce.ToIntNode;
import org.jruby.truffle.nodes.coerce.ToIntNodeFactory;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.nodes.methods.arguments.MissingArgumentBehaviour;
import org.jruby.truffle.nodes.methods.arguments.ReadPreArgumentNode;
@@ -446,8 +449,12 @@ public Object setIntegerFixnumRange(VirtualFrame frame, RubyArray array, RubyRan

}

@CoreMethod(names = "at", required = 1, lowerFixnumParameters = 0)
public abstract static class AtNode extends ArrayCoreMethodNode {
@CoreMethod(names = "at", required = 1)
@NodeChildren({
@NodeChild(value = "array"),
@NodeChild(value = "index")
})
public abstract static class AtNode extends RubyNode {

@Child private ArrayReadDenormalizedNode readNode;

@@ -460,6 +467,10 @@ public AtNode(AtNode prev) {
readNode = prev.readNode;
}

@CreateCast("index") public RubyNode coerceOtherToInt(RubyNode index) {
return ToIntNodeFactory.create(getContext(), getSourceSection(), index);
}

@Specialization
public Object at(VirtualFrame frame, RubyArray array, int index) {
if (readNode == null) {