Skip to content

Commit 1a52b2a

Browse files
committedJul 31, 2018
pass runtime through
1 parent f876e0f commit 1a52b2a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed
 

‎core/src/main/java/org/jruby/RubyMatchData.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ private static int nameToBackrefNumber(Ruby runtime, Regex pattern, Region regs,
488488
}
489489
}
490490

491-
public final int backrefNumber(IRubyObject obj) {
491+
public final int backrefNumber(Ruby runtime, IRubyObject obj) {
492492
check();
493-
return backrefNumber(getRuntime(), getPattern(), regs, obj);
493+
return backrefNumber(runtime, getPattern(), regs, obj);
494494
}
495495

496496
public static int backrefNumber(Ruby runtime, Regex pattern, Region regs, IRubyObject obj) {
@@ -630,11 +630,10 @@ public IRubyObject size(ThreadContext context) {
630630
*/
631631
@JRubyMethod
632632
public IRubyObject begin(ThreadContext context, IRubyObject index) {
633-
Ruby runtime = context.runtime;
634-
635-
int i = backrefNumber(index);
636-
637633
check();
634+
final Ruby runtime = context.runtime;
635+
final int i = backrefNumber(runtime, index);
636+
638637
if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) {
639638
throw runtime.newIndexError("index " + i + " out of matches");
640639
}
@@ -656,7 +655,7 @@ public IRubyObject end(ThreadContext context, IRubyObject index) {
656655
check();
657656

658657
final Ruby runtime = context.runtime;
659-
final int i = backrefNumber(index);
658+
final int i = backrefNumber(runtime, index);
660659

661660
if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) {
662661
throw runtime.newIndexError("index " + i + " out of matches");
@@ -686,11 +685,12 @@ public IRubyObject offset19(ThreadContext context, IRubyObject index) {
686685
check();
687686

688687
final Ruby runtime = context.runtime;
689-
final int i = backrefNumber(index);
688+
final int i = backrefNumber(runtime, index);
690689

691690
if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) {
692691
throw runtime.newIndexError("index " + i + " out of matches");
693692
}
693+
694694
int b, e;
695695
if (regs == null) {
696696
b = begin;

‎core/src/main/java/org/jruby/RubyRegexp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ public static IRubyObject getBackRef(ThreadContext context) {
781781
public static IRubyObject last_match_s(ThreadContext context, IRubyObject recv, IRubyObject nth) {
782782
IRubyObject match = context.getBackRef();
783783
if (match.isNil()) return match;
784-
return nth_match(((RubyMatchData)match).backrefNumber(nth), match);
784+
return nth_match(((RubyMatchData)match).backrefNumber(context.runtime, nth), match);
785785
}
786786

787787
/** rb_reg_s_union

‎core/src/main/java/org/jruby/RubyString.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ private void subpatSet(ThreadContext context, RubyRegexp regexp, IRubyObject bac
35903590
// this cast should be ok, since nil matchdata will be < 0 above
35913591
RubyMatchData match = (RubyMatchData)context.getBackRef();
35923592

3593-
int nth = backref == null ? 0 : subpatSetCheck(runtime, match.backrefNumber(backref), match.regs);
3593+
int nth = backref == null ? 0 : subpatSetCheck(runtime, match.backrefNumber(context.runtime, backref), match.regs);
35943594

35953595
final int start, end;
35963596
if (match.regs == null) {
@@ -3613,7 +3613,7 @@ private IRubyObject subpat(ThreadContext context, RubyRegexp regex, IRubyObject
36133613

36143614
if (result >= 0) {
36153615
RubyMatchData match = (RubyMatchData)context.getBackRef();
3616-
return RubyRegexp.nth_match(match.backrefNumber(backref), match);
3616+
return RubyRegexp.nth_match(match.backrefNumber(context.runtime, backref), match);
36173617
}
36183618

36193619
return context.nil;

0 commit comments

Comments
 (0)
Please sign in to comment.