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

Commits on Jun 5, 2015

  1. Copy the full SHA
    df43152 View commit details
  2. Copy the full SHA
    d59865b View commit details
8 changes: 0 additions & 8 deletions spec/truffle/tags/core/enumerable/chunk_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/enumerable/cycle_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:Enumerable#cycle passed no argument or nil loops indefinitely
fails:Enumerable#cycle Enumerable with size when no block is given returned Enumerator size should be the result of multiplying the enumerable size by the argument passed
fails:Enumerable#cycle Enumerable with size when no block is given returned Enumerator size should be zero when the argument passed is 0 or less
fails:Enumerable#cycle Enumerable with size when no block is given returned Enumerator size should be Float::INFINITY when no argument is passed
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/enumerable/slice_before_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -10,7 +10,9 @@

package org.jruby.truffle.nodes.core;

import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyRegexp;
import org.jruby.util.StringSupport;

public class RegexpGuards {

@@ -22,4 +24,8 @@ public static boolean isRegexpLiteral(RubyRegexp regexp) {
return regexp.getOptions().isLiteral();
}

public static boolean isValidEncoding(RubyBasicObject string) {
return StringNodes.scanForCodeRange(string) != StringSupport.CR_BROKEN;
}

}
Original file line number Diff line number Diff line change
@@ -99,24 +99,29 @@ public int optionsNotInitialized(RubyRegexp regexp) {
}

@RubiniusPrimitive(name = "regexp_search_region", lowerFixnumParameters = {1, 2})
@ImportStatic(RegexpGuards.class)
public static abstract class RegexpSearchRegionPrimitiveNode extends RubiniusPrimitiveNode {

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

@TruffleBoundary
@Specialization
public Object searchRegion(RubyRegexp regexp, RubyString string, int start, int end, boolean forward) {
if (regexp.getRegex() == null) {
throw new RaiseException(getContext().getCoreLibrary().typeError("uninitialized Regexp", this));
}
@Specialization(guards = "!isInitialized(regexp)")
public Object searchRegionNotInitialized(RubyRegexp regexp, RubyString string, int start, int end, boolean forward) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeError("uninitialized Regexp", this));
}

if (StringNodes.scanForCodeRange(string) == StringSupport.CR_BROKEN) {
throw new RaiseException(getContext().getCoreLibrary().argumentError(
String.format("invalid byte sequence in %s", StringNodes.getByteList(string).getEncoding()), this));
}
@Specialization(guards = "!isValidEncoding(string)")
public Object searchRegionInvalidEncoding(RubyRegexp regexp, RubyString string, int start, int end, boolean forward) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError(
String.format("invalid byte sequence in %s", StringNodes.getByteList(string).getEncoding()), this));
}

@TruffleBoundary
@Specialization(guards = { "isInitialized(regexp)", "isValidEncoding(string)" })
public Object searchRegion(RubyRegexp regexp, RubyString string, int start, int end, boolean forward) {
final ByteList bl = regexp.getSource();
final Regex r = new Regex(bl.getUnsafeBytes(), bl.getBegin(), bl.getBegin() + bl.getRealSize(), regexp.getRegex().getOptions(), regexp.checkEncoding(StringNodes.getCodeRangeable(string), true));
final Matcher matcher = r.matcher(StringNodes.getByteList(string).bytes());