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

Commits on Mar 13, 2015

  1. Copy the full SHA
    8f440e1 View commit details
  2. Merge pull request #2696 from bjfish/truffle_array_delete_at_to_ary

    [Truffle] Adding #to_ary to Array#delete_at
    chrisseaton committed Mar 13, 2015
    Copy the full SHA
    fc0fe19 View commit details
Showing with 11 additions and 3 deletions.
  1. +1 −2 spec/truffle/tags/core/array/delete_at_tags.txt
  2. +10 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
3 changes: 1 addition & 2 deletions spec/truffle/tags/core/array/delete_at_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:Array#delete_at returns nil and makes no modification if the index is out of range
fails:Array#delete_at tries to convert the passed argument to an Integer using #to_int
fails:Array#delete_at returns nil and makes no modification if the index is out of range
Original file line number Diff line number Diff line change
@@ -755,7 +755,12 @@ public Object deleteObject(VirtualFrame frame, RubyArray array, Object value) {
}

@CoreMethod(names = "delete_at", required = 1, raiseIfFrozenSelf = true)
public abstract static class DeleteAtNode extends ArrayCoreMethodNode {
@NodeChildren({
@NodeChild(value = "array"),
@NodeChild(value = "index")
})
@ImportGuards(ArrayGuards.class)
public abstract static class DeleteAtNode extends RubyNode {

private final BranchProfile tooSmallBranch = BranchProfile.create();
private final BranchProfile beyondEndBranch = BranchProfile.create();
@@ -768,6 +773,10 @@ public DeleteAtNode(DeleteAtNode prev) {
super(prev);
}

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

@Specialization(guards = "isIntegerFixnum", rewriteOn = UnexpectedResultException.class)
public int deleteAtIntegerFixnumInBounds(RubyArray array, int index) throws UnexpectedResultException {
final int normalizedIndex = array.normalizeIndex(index);