Skip to content

Commit

Permalink
Merge pull request jruby#8548 from enebo/regex
Browse files Browse the repository at this point in the history
tcification of regex
  • Loading branch information
enebo authored Dec 26, 2024
2 parents 3c88b28 + ce0c411 commit 7dfd5a1
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 341 deletions.
16 changes: 8 additions & 8 deletions core/src/main/java/org/jruby/RubyComplex.java
Original file line number Diff line number Diff line change
Expand Up @@ -1289,8 +1289,8 @@ static IRubyObject[] str_to_c_internal(ThreadContext context, RubyString str) {

if (m != nil) {
RubyMatchData match = (RubyMatchData)m;
sr = match.at(1);
si = match.at(2);
sr = match.at(context, 1);
si = match.at(context, 2);
re = match.post_match(context);
po = true;
}
Expand All @@ -1301,9 +1301,9 @@ static IRubyObject[] str_to_c_internal(ThreadContext context, RubyString str) {
if (m != nil) {
RubyMatchData match = (RubyMatchData)m;
sr = nil;
si = match.at(1);
si = match.at(context, 1);
if (si == nil) si = runtime.newString();
IRubyObject t = match.at(2);
IRubyObject t = match.at(context, 2);
if (t == nil) t = runtime.newString(RubyInteger.singleCharByteList((byte) '1'));
((RubyString) (si = si.convertToString())).cat(t.convertToString());
re = match.post_match(context);
Expand All @@ -1315,12 +1315,12 @@ static IRubyObject[] str_to_c_internal(ThreadContext context, RubyString str) {
m = RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.comp_pat2).match_m(context, str, false);
if (m == nil) return new IRubyObject[] { context.nil, str };
RubyMatchData match = (RubyMatchData) m;
sr = match.at(1);
if (match.at(2) == nil) {
sr = match.at(context, 1);
if (match.at(context, 2) == nil) {
si = context.nil;
} else {
si = match.at(3);
IRubyObject t = match.at(4);
si = match.at(context, 3);
IRubyObject t = match.at(context, 4);
if (t == nil) t = runtime.newString(RubyInteger.singleCharByteList((byte) '1'));
((RubyString) (si = si.convertToString())).cat(t.convertToString());
}
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/RubyGlobal.java
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ public PreMatchGlobalVariable(Ruby runtime, String name) {

@Override
public IRubyObject get() {
return RubyRegexp.match_pre(runtime.getCurrentContext().getBackRef());
var context = runtime.getCurrentContext();
return RubyRegexp.match_pre(context, context.getBackRef());
}
}

Expand All @@ -940,7 +941,8 @@ public LastMatchGlobalVariable(Ruby runtime, String name) {

@Override
public IRubyObject get() {
return RubyRegexp.match_last(runtime.getCurrentContext().getBackRef());
var context = runtime.getCurrentContext();
return RubyRegexp.match_last(context, context.getBackRef());
}
}

Expand Down
Loading

0 comments on commit 7dfd5a1

Please sign in to comment.