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: 22d9d361cd8d
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 48bd23beb1f3
Choose a head ref
  • 9 commits
  • 8 files changed
  • 1 contributor

Commits on Apr 9, 2018

  1. Copy the full SHA
    a9d8bf0 View commit details
  2. Copy the full SHA
    ea7cdda View commit details
  3. Copy the full SHA
    30768ff View commit details
  4. Copy the full SHA
    58db090 View commit details
  5. Copy the full SHA
    0819b65 View commit details
  6. Copy the full SHA
    15d3717 View commit details
  7. Copy the full SHA
    4cfc10e View commit details
  8. Copy the full SHA
    d108017 View commit details
  9. Copy the full SHA
    48bd23b View commit details
14 changes: 12 additions & 2 deletions core/src/main/java/org/jruby/RubyBignum.java
Original file line number Diff line number Diff line change
@@ -870,7 +870,12 @@ public IRubyObject op_lshift(ThreadContext context, IRubyObject other) {
other = other.convertToInteger();
}

return bignorm(context.runtime, value.shiftLeft((int)shift));
return op_lshift(context, shift);
}

@Override
public RubyInteger op_lshift(ThreadContext context, long shift) {
return bignorm(context.runtime, value.shiftLeft((int) shift));
}

/** rb_big_rshift
@@ -896,7 +901,12 @@ public IRubyObject op_rshift(ThreadContext context, IRubyObject other) {
other = other.convertToInteger();
}

return bignorm(context.runtime, value.shiftRight((int)shift));
return op_rshift(context, shift);
}

@Override
public RubyInteger op_rshift(ThreadContext context, long shift) {
return bignorm(context.runtime, value.shiftRight((int) shift));
}

/** rb_big_aref
36 changes: 24 additions & 12 deletions core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -1261,18 +1261,24 @@ public IRubyObject op_lshift(ThreadContext context, IRubyObject other) {
return RubyBignum.newBignum(context.runtime, value).op_lshift(context, other);
}

return op_lshift(((RubyFixnum) other).getLongValue());
return op_lshift(context, ((RubyFixnum) other).getLongValue());
}

public IRubyObject op_lshift(long width) {
return width < 0 ? rshift(-width) : lshift(width);
@Override
public RubyInteger op_lshift(ThreadContext context, final long width) {
return width < 0 ? rshift(context, -width) : lshift(context, width);
}

private IRubyObject lshift(long width) {
private RubyInteger lshift(ThreadContext context, final long width) {
if (width > BIT_SIZE - 1 || ((~0L << BIT_SIZE - width - 1) & value) != 0) {
return RubyBignum.newBignum(getRuntime(), value).op_lshift(RubyFixnum.newFixnum(getRuntime(), width));
return RubyBignum.newBignum(context.runtime, value).op_lshift(context, width);
}
return RubyFixnum.newFixnum(getRuntime(), value << width);
return RubyFixnum.newFixnum(context.runtime, value << width);
}

@Deprecated // no longer used
public IRubyObject op_lshift(long width) {
return op_lshift(getRuntime().getCurrentContext(), width);
}

/** fix_rshift
@@ -1284,20 +1290,26 @@ public IRubyObject op_rshift(ThreadContext context, IRubyObject other) {
return RubyBignum.newBignum(context.runtime, value).op_rshift(context, other);
}

return op_rshift(((RubyFixnum) other).getLongValue());
return op_rshift(context, ((RubyFixnum) other).getLongValue());
}

public IRubyObject op_rshift(long width) {
@Override
public RubyInteger op_rshift(ThreadContext context, final long width) {
if (width == 0) return this;

return width < 0 ? lshift(-width) : rshift(width);
return width < 0 ? lshift(context, -width) : rshift(context, width);
}

private IRubyObject rshift(long width) {
private RubyFixnum rshift(ThreadContext context, final long width) {
if (width >= BIT_SIZE - 1) {
return value < 0 ? RubyFixnum.minus_one(getRuntime()) : RubyFixnum.zero(getRuntime());
return value < 0 ? RubyFixnum.minus_one(context.runtime) : RubyFixnum.zero(context.runtime);
}
return RubyFixnum.newFixnum(getRuntime(), value >> width);
return RubyFixnum.newFixnum(context.runtime, value >> width);
}

@Deprecated
public IRubyObject op_rshift(long width) {
return op_rshift(getRuntime().getCurrentContext(), width);
}

/** fix_to_f
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/RubyInteger.java
Original file line number Diff line number Diff line change
@@ -863,9 +863,17 @@ public IRubyObject magnitude(ThreadContext context) {
@JRubyMethod(name = "<<")
public abstract IRubyObject op_lshift(ThreadContext context, IRubyObject other);

public RubyInteger op_lshift(ThreadContext context, long other) {
return (RubyInteger) op_lshift(context, RubyFixnum.newFixnum(context.runtime, other));
}

@JRubyMethod(name = ">>")
public abstract IRubyObject op_rshift(ThreadContext context, IRubyObject other);

public RubyInteger op_rshift(ThreadContext context, long other) {
return (RubyInteger) op_rshift(context, RubyFixnum.newFixnum(context.runtime, other));
}

@JRubyMethod(name = "to_f")
public abstract IRubyObject to_f(ThreadContext context);

@@ -924,10 +932,12 @@ public IRubyObject op_aref(IRubyObject other) {
return op_aref(getRuntime().getCurrentContext(), other);
}

@Deprecated // no longer used
public IRubyObject op_lshift(IRubyObject other) {
return op_lshift(getRuntime().getCurrentContext(), other);
}

@Deprecated // no longer used
public IRubyObject op_rshift(IRubyObject other) {
return op_rshift(getRuntime().getCurrentContext(), other);
}
11 changes: 10 additions & 1 deletion core/src/main/java/org/jruby/RubyRational.java
Original file line number Diff line number Diff line change
@@ -1235,12 +1235,21 @@ public int hashCode() {
return num.hashCode() ^ den.hashCode();
}

@Override
public IRubyObject to_s() {
return to_s(getRuntime());
}

/** nurat_to_s
*
*/
@JRubyMethod(name = "to_s")
public RubyString to_s(ThreadContext context) {
RubyString str = RubyString.newString(context.runtime, new ByteList(10), USASCIIEncoding.INSTANCE);
return to_s(context.runtime);
}

private RubyString to_s(final Ruby runtime) {
RubyString str = RubyString.newString(runtime, new ByteList(10), USASCIIEncoding.INSTANCE);
str.append(num.to_s());
str.cat((byte)'/');
str.append(den.to_s());
Loading