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

Commits on Jun 1, 2015

  1. Copy the full SHA
    7344cfc View commit details
  2. Copy the full SHA
    ff5fb68 View commit details
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/matchdata/eql_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/matchdata/equal_value_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/matchdata/offset_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:MatchData#offset returns a two element array with the begin and end of the nth match
fails:MatchData#offset returns [nil, nil] when the nth match isn't found
fails:MatchData#offset returns the offset for multi byte strings
fails:MatchData#offset returns the offset for multi byte strings with unicode regexp
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/matchdata/regexp_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/matchdata/string_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -298,4 +298,17 @@ public RubyBasicObject rubiniusSource(RubyMatchData matchData) {
}
}

@CoreMethod(names = "regexp")
public abstract static class RegexpNode extends CoreMethodArrayArgumentsNode {

public RegexpNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public RubyBasicObject regexp(RubyMatchData matchData) {
return matchData.getRegexp();
}
}

}
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.runtime.core;

import org.joni.Regex;
import org.joni.Region;
import org.jruby.truffle.runtime.array.ArrayUtils;
import org.jruby.truffle.runtime.subsystems.ObjectSpaceManager;
@@ -23,17 +22,17 @@
public class RubyMatchData extends RubyBasicObject {

private final RubyBasicObject source;
private final Regex regex;
private final RubyRegexp regexp;
private final Region region;
private final Object[] values;
private final RubyBasicObject pre;
private final RubyBasicObject post;
private final RubyBasicObject global;

public RubyMatchData(RubyClass rubyClass, RubyBasicObject source, Regex regex, Region region, Object[] values, RubyBasicObject pre, RubyBasicObject post, RubyBasicObject global) {
public RubyMatchData(RubyClass rubyClass, RubyBasicObject source, RubyRegexp regexp, Region region, Object[] values, RubyBasicObject pre, RubyBasicObject post, RubyBasicObject global) {
super(rubyClass);
this.source = source;
this.regex = regex;
this.regexp = regexp;
this.region = region;
this.values = values;
this.pre = pre;
@@ -94,7 +93,7 @@ public int getNumberOfRegions() {
}

public int getBackrefNumber(ByteList value) {
return regex.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), region);
return regexp.getRegex().nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), region);
}

@Override
@@ -126,4 +125,5 @@ public RubyBasicObject getSource() {
return source;
}

public RubyBasicObject getRegexp() { return regexp; }
}
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ public Object matchCommon(RubyString source, boolean operator, boolean setNamedC
final RubyBasicObject post = makeString(source, region.end[0], bytes.length() - region.end[0]);
final RubyBasicObject global = makeString(source, region.beg[0], region.end[0] - region.beg[0]);

final RubyMatchData matchObject = new RubyMatchData(context.getCoreLibrary().getMatchDataClass(), source, regex, region, values, pre, post, global);
final RubyMatchData matchObject = new RubyMatchData(context.getCoreLibrary().getMatchDataClass(), source, this, region, values, pre, post, global);

if (operator) {
if (values.length > 0) {