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

Commits on Jul 6, 2017

  1. Copy the full SHA
    8093c2a View commit details
  2. Copy the full SHA
    6250392 View commit details
24 changes: 12 additions & 12 deletions core/src/main/java/org/jruby/RubyComplex.java
Original file line number Diff line number Diff line change
@@ -996,42 +996,42 @@ static RubyArray str_to_c_internal(ThreadContext context, IRubyObject recv) {
IRubyObject sr, si, re;
sr = si = re = runtime.getNil();
boolean po = false;
IRubyObject m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat0).match_m19(context, s, false, Block.NULL_BLOCK);
IRubyObject m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat0).match_m(context, s, false);

if (!m.isNil()) {
RubyMatchData match = (RubyMatchData)m;
sr = match.op_aref19(RubyFixnum.one(runtime));
si = match.op_aref19(RubyFixnum.two(runtime));
sr = match.at(1);
si = match.at(2);
re = match.post_match(context);
po = true;
}

if (m.isNil()) {
m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat1).match_m19(context, s, false, Block.NULL_BLOCK);
m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat1).match_m(context, s, false);

if (!m.isNil()) {
RubyMatchData match = (RubyMatchData)m;
sr = runtime.getNil();
si = match.op_aref19(RubyFixnum.one(runtime));
si = match.at(1);
if (si.isNil()) si = runtime.newString();
IRubyObject t = match.op_aref19(RubyFixnum.two(runtime));
if (t.isNil()) t = runtime.newString(new ByteList(new byte[]{'1'}));
IRubyObject t = match.at(2);
if (t.isNil()) t = runtime.newString(new ByteList(new byte[]{'1'}, false));
si.convertToString().cat(t.convertToString().getByteList());
re = match.post_match(context);
po = false;
}
}

if (m.isNil()) {
m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat2).match_m19(context, s, false, Block.NULL_BLOCK);
m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat2).match_m(context, s, false);
if (m.isNil()) return runtime.newArray(runtime.getNil(), recv);
RubyMatchData match = (RubyMatchData)m;
sr = match.op_aref19(RubyFixnum.one(runtime));
if (match.op_aref19(RubyFixnum.two(runtime)).isNil()) {
sr = match.at(1);
if (match.at(2).isNil()) {
si = runtime.getNil();
} else {
si = match.op_aref19(RubyFixnum.three(runtime));
IRubyObject t = match.op_aref19(RubyFixnum.four(runtime));
si = match.at(3);
IRubyObject t = match.at(4);
if (t.isNil()) t = runtime.newString(RubyFixnum.SINGLE_CHAR_BYTELISTS19['1']);
si.convertToString().cat(t.convertToString().getByteList());
}
24 changes: 12 additions & 12 deletions core/src/main/java/org/jruby/RubyMatchData.java
Original file line number Diff line number Diff line change
@@ -482,25 +482,21 @@ public static int backrefNumber(Ruby runtime, Regex pattern, Region regs, IRubyO
}
}

/** match_aref
*
*/
public IRubyObject op_aref(IRubyObject idx) {
return op_aref19(idx);
@Deprecated
public IRubyObject op_aref19(IRubyObject idx) {
return op_aref(idx);
}

/** match_aref
*
*/
public IRubyObject op_aref(IRubyObject idx, IRubyObject rest) {
return op_aref19(idx, rest);
@Deprecated
public IRubyObject op_aref19(IRubyObject idx, IRubyObject rest) {
return op_aref(idx, rest);
}

/** match_aref
*
*/
@JRubyMethod(name = "[]")
public IRubyObject op_aref19(IRubyObject idx) {
public IRubyObject op_aref(IRubyObject idx) {
check();
IRubyObject result = op_arefCommon(idx);
return result == null ? to_a().aref(idx) : result;
@@ -510,7 +506,7 @@ public IRubyObject op_aref19(IRubyObject idx) {
*
*/
@JRubyMethod(name = "[]")
public IRubyObject op_aref19(IRubyObject idx, IRubyObject rest) {
public IRubyObject op_aref(IRubyObject idx, IRubyObject rest) {
IRubyObject result;
return !rest.isNil() || (result = op_arefCommon(idx)) == null ? to_a().aref(idx, rest) : result;
}
@@ -529,6 +525,10 @@ private IRubyObject op_arefCommon(IRubyObject idx) {
return null;
}

public final IRubyObject at(final int nth) {
return RubyRegexp.nth_match(nth, this);
}

/** match_size
*
*/
11 changes: 5 additions & 6 deletions core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -769,7 +769,7 @@ public final IRubyObject div19(ThreadContext context, IRubyObject other) {
*/
@JRubyMethod(name = "divmod")
public IRubyObject divmod(ThreadContext context, IRubyObject other) {
return RubyArray.newArray(context.runtime, div(context, other), modulo19(context, other));
return RubyArray.newArray(context.runtime, div(context, other), modulo(context, other));
}

@Deprecated
@@ -806,25 +806,24 @@ public final IRubyObject modulo19(ThreadContext context, IRubyObject other) {
public IRubyObject remainder(ThreadContext context, IRubyObject dividend) {
IRubyObject z = sites(context).op_mod.call(context, this, this, dividend);
IRubyObject x = this;
RubyFixnum zero = RubyFixnum.zero(getRuntime());
RubyFixnum zero = RubyFixnum.zero(context.runtime);

if (!equalInternal(context, z, zero) &&
((sites(context).op_lt.call(context, x, x, zero).isTrue() &&
sites(context).op_gt.call(context, dividend, dividend, zero).isTrue()) ||
(sites(context).op_gt.call(context, x, x, zero).isTrue() &&
sites(context).op_lt.call(context, dividend, dividend, zero).isTrue()))) {
return sites(context).op_minus.call(context, z, z, dividend);
} else {
return z;
}
return z;
}

/** num_abs
*
*/
@JRubyMethod(name = "abs")
public IRubyObject abs(ThreadContext context) {
if (sites(context).op_lt.call(context, this, this, RubyFixnum.zero(getRuntime())).isTrue()) {
if (sites(context).op_lt.call(context, this, this, RubyFixnum.zero(context.runtime)).isTrue()) {
return sites(context).op_uminus.call(context, this, this);
}
return this;
@@ -876,7 +875,7 @@ public IRubyObject zero_p(ThreadContext context) {
@JRubyMethod(name = "nonzero?")
public IRubyObject nonzero_p(ThreadContext context) {
if (sites(context).zero.call(context, this, this).isTrue()) {
return getRuntime().getNil();
return context.nil;
}
return this;
}
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyRational.java
Original file line number Diff line number Diff line change
@@ -1047,13 +1047,13 @@ static RubyArray str_to_r_internal(ThreadContext context, IRubyObject recv) {
Ruby runtime = context.runtime;
if (bytes.getRealSize() == 0) return runtime.newArray(runtime.getNil(), recv);

IRubyObject m = RubyRegexp.newDummyRegexp(runtime, Numeric.RationalPatterns.rat_pat).match_m19(context, s, false, Block.NULL_BLOCK);
IRubyObject m = RubyRegexp.newDummyRegexp(runtime, Numeric.RationalPatterns.rat_pat).match_m(context, s, false);

if (!m.isNil()) {
RubyMatchData match = (RubyMatchData)m;
IRubyObject si = match.op_aref19(RubyFixnum.one(runtime));
RubyString nu = (RubyString)match.op_aref19(RubyFixnum.two(runtime));
IRubyObject de = match.op_aref19(RubyFixnum.three(runtime));
IRubyObject si = match.at(1);
RubyString nu = (RubyString)match.at(2);
IRubyObject de = match.at(3);
IRubyObject re = match.post_match(context);

RubyArray a = nu.split19(RubyRegexp.newDummyRegexp(runtime, Numeric.RationalPatterns.an_e_pat), context, false).convertToArray();
Loading