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

Commits on Mar 3, 2015

  1. Copy the full SHA
    13b160b View commit details
  2. Copy the full SHA
    6353556 View commit details
  3. Copy the full SHA
    894a37c View commit details
1 change: 0 additions & 1 deletion spec/truffle/tags/core/range/each_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
fails:Range#each passes each element to the given block by using #succ
fails:Range#each raises a TypeError if the first element does not respond to #succ
fails:Range#each returns an enumerator when no block given
fails:Range#each passes each Symbol element by using #succ
fails:Range#each raises a TypeError if the first element is a Time object
1 change: 0 additions & 1 deletion spec/truffle/tags/core/range/equal_value_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:Range#== returns true if other has same begin, end, and exclude_end? values
fails:Range#== returns false if other is no Range
fails:Range#== returns true for subclasses to Range
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/range/exclude_end_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/range/initialize_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
fails:Range#initialize initializes correctly the Range object when given 2 arguments
fails:Range#initialize initializes correctly the Range object when given 3 arguments
fails:Range#initialize raises an ArgumentError if passed without or with only one argument
fails:Range#initialize raises a NameError if called on an already initialized Range
fails:Range#initialize raises an ArgumentError if arguments don't respond to <=>
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/range/inspect_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
fails:Range#inspect provides a printable form, using #inspect to convert the start and end objects
fails:Range#inspect returns a tainted string if either end is tainted
fails:Range#inspect ignores own tainted status
fails:Range#inspect returns a untrusted string if either end is untrusted
fails:Range#inspect ignores own untrusted status
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/range/max_tags.txt
Original file line number Diff line number Diff line change
@@ -4,8 +4,4 @@ fails:Range#max returns nil when the endpoint is less than the start point
fails:Range#max returns nil when the endpoint is less than the start point in a Float range
fails:Range#max returns end point when the range is Time..Time(included end point)
fails:Range#max raises TypeError when called on a Time...Time(excluded end point)
fails:Range#max given a block passes each pair of values in the range to the block
fails:Range#max given a block passes each pair of elements to the block in reversed order
fails:Range#max given a block calls #> and #< on the return value of the block
fails:Range#max given a block returns the element the block determines to be the maximum
fails:Range#max given a block returns nil when the endpoint is less than the start point
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/range/min_tags.txt
Original file line number Diff line number Diff line change
@@ -4,8 +4,4 @@ fails:Range#min returns nil when the start point is greater than the endpoint
fails:Range#min returns nil when the start point is greater than the endpoint in a Float range
fails:Range#min returns start point when the range is Time..Time(included end point)
fails:Range#min returns start point when the range is Time...Time(excluded end point)
fails:Range#min given a block passes each pair of values in the range to the block
fails:Range#min given a block passes each pair of elements to the block where the first argument is the current element, and the last is the first element
fails:Range#min given a block calls #> and #< on the return value of the block
fails:Range#min given a block returns the element the block determines to be the minimum
fails:Range#min given a block returns nil when the start point is greater than the endpoint
1 change: 0 additions & 1 deletion spec/truffle/tags/core/range/new_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:Range.new constructs a range using the given start and end
fails:Range.new includes the end object when the third parameter is omitted or false
fails:Range.new raises an ArgumentError when the given start and end can't be compared by using #<=>
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/byteslice_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:String#byteslice with index, length returns subclass instances
fails:String#byteslice with Range returns subclass instances
fails:String#byteslice with Range calls to_int on range arguments
Original file line number Diff line number Diff line change
@@ -9,13 +9,18 @@
*/
package org.jruby.truffle.nodes.literal;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyRange;

@NodeChildren({@NodeChild("begin"), @NodeChild("end")})
@@ -29,6 +34,8 @@ public abstract class RangeLiteralNode extends RubyNode {
private final BranchProfile endLongProfile = BranchProfile.create();
private final BranchProfile objectProfile = BranchProfile.create();

@Child private CallDispatchHeadNode cmpNode;

public RangeLiteralNode(RubyContext context, SourceSection sourceSection, boolean excludeEnd) {
super(context, sourceSection);
this.excludeEnd = excludeEnd;
@@ -59,7 +66,7 @@ public RubyRange.LongFixnumRange doRange(long begin, long end) {
}

@Specialization
public Object doRange(Object begin, Object end) {
public Object doRange(VirtualFrame frame, Object begin, Object end) {
if (begin instanceof Integer) {
beginIntegerProfile.enter();

@@ -88,6 +95,23 @@ public Object doRange(Object begin, Object end) {

objectProfile.enter();

if (cmpNode == null) {
CompilerDirectives.transferToInterpreter();
cmpNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
}

final Object cmpResult;

try {
cmpResult = cmpNode.call(frame, begin, "<=>", null, end);
} catch (RaiseException e) {
throw new RaiseException(getContext().getCoreLibrary().argumentError("bad value for range", this));
}

if (cmpResult == getContext().getCoreLibrary().getNilObject()) {
throw new RaiseException(getContext().getCoreLibrary().argumentError("bad value for range", this));
}

return new RubyRange.ObjectRange(getContext().getCoreLibrary().getRangeClass(), begin, end, excludeEnd);
}