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

Commits on Jun 8, 2015

  1. Copy the full SHA
    6e8f8d5 View commit details
  2. Copy the full SHA
    d055bfa View commit details
8 changes: 0 additions & 8 deletions spec/truffle/tags/core/string/match_tags.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
fails(regexp):String#=~ invokes obj.=~ with self if obj is neither a string nor regexp
fails(regexp):String#=~ returns the character index of a found match
fails(regexp):String#match matches a literal Regexp that uses ASCII-only UTF-8 escape sequences
fails(regexp):String#match tries to convert pattern to a string via to_str
fails(regexp):String#match with [pattern, position] when given a positive position matches the pattern against self starting at an optional index
fails(regexp):String#match with [pattern, position] when given a positive position uses the start as a character offset
fails(regexp):String#match with [pattern, position] when given a negative position matches the pattern against self starting at an optional index
fails(regexp):String#match with [pattern, position] when given a negative position uses the start as a character offset
fails(regexp):String#match when passed a block yields the MatchData
fails(regexp):String#match when passed a block returns the block result
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jcodings.specific.USASCIIEncoding;
import org.jruby.truffle.nodes.cast.BooleanCastNode;
import org.jruby.truffle.nodes.cast.BooleanCastNodeGen;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
@@ -701,7 +702,7 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public RubyBasicObject toS(RubyBasicObject value, NotProvided base) {
return createString(getBigIntegerValue(value).toString());
return createString(getBigIntegerValue(value).toString(), USASCIIEncoding.INSTANCE);
}

@TruffleBoundary
@@ -712,7 +713,7 @@ public RubyBasicObject toS(RubyBasicObject value, int base) {
throw new RaiseException(getContext().getCoreLibrary().argumentErrorInvalidRadix(base, this));
}

return createString(getBigIntegerValue(value).toString(base));
return createString(getBigIntegerValue(value).toString(base), USASCIIEncoding.INSTANCE);
}

}
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jcodings.specific.USASCIIEncoding;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.NotProvided;
@@ -678,7 +679,7 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public RubyBasicObject toS(double value) {
return createString(Double.toString(value));
return createString(Double.toString(value), USASCIIEncoding.INSTANCE);
}

}
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import org.jcodings.exception.EncodingException;
import org.jcodings.specific.ASCIIEncoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.joni.Matcher;
import org.joni.Option;
import org.jruby.Ruby;
@@ -245,11 +246,12 @@ public static RubyBasicObject createEmptyString(RubyClass stringClass) {
}

public static RubyBasicObject createString(RubyClass stringClass, String string) {
return createString(stringClass, string, USASCIIEncoding.INSTANCE);
return createString(stringClass, string, UTF8Encoding.INSTANCE);
}

@TruffleBoundary
public static RubyBasicObject createString(RubyClass stringClass, String string, Encoding encoding) {
return createString(stringClass, new ByteList(org.jruby.RubyEncoding.encodeUTF8(string), encoding, false));
return createString(stringClass, org.jruby.RubyString.encodeBytelist(string, encoding));
}

public static RubyBasicObject createString(RubyClass stringClass, byte[] bytes) {
@@ -740,19 +742,6 @@ private StringPrimitiveNodes.StringSubstringPrimitiveNode getSubstringNode() {
}
}

@CoreMethod(names = "=~", required = 1)
public abstract static class MatchOperatorNode extends CoreMethodArrayArgumentsNode {

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

@Specialization
public Object match(RubyString string, RubyRegexp regexp) {
return regexp.matchCommon(string, true, false);
}
}

@CoreMethod(names = "ascii_only?")
public abstract static class ASCIIOnlyNode extends CoreMethodArrayArgumentsNode {

@@ -1515,28 +1504,6 @@ public Object lstripBang(RubyString string) {
}
}

@CoreMethod(names = "match", required = 1, taintFromSelf = true)
public abstract static class MatchNode extends CoreMethodArrayArgumentsNode {

@Child private CallDispatchHeadNode regexpMatchNode;

public MatchNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
regexpMatchNode = DispatchHeadNodeFactory.createMethodCall(context);
}

@Specialization
public Object match(VirtualFrame frame, RubyString string, RubyString regexpString) {
final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), getByteList(regexpString), Option.DEFAULT);
return regexpMatchNode.call(frame, regexp, "match", null, string);
}

@Specialization
public Object match(VirtualFrame frame, RubyString string, RubyRegexp regexp) {
return regexpMatchNode.call(frame, regexp, "match", null, string);
}
}

@RubiniusOnly
@CoreMethod(names = "modify!", raiseIfFrozenSelf = true)
public abstract static class ModifyBangNode extends CoreMethodArrayArgumentsNode {
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jcodings.specific.USASCIIEncoding;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
@@ -1113,13 +1114,13 @@ public InspectNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public RubyBasicObject inspect(int n) {
return createString(Integer.toString(n));
return createString(Integer.toString(n), USASCIIEncoding.INSTANCE);
}

@TruffleBoundary
@Specialization
public RubyBasicObject inspect(long n) {
return createString(Long.toString(n));
return createString(Long.toString(n), USASCIIEncoding.INSTANCE);
}

}
@@ -1167,13 +1168,13 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public RubyBasicObject toS(int n, NotProvided base) {
return createString(Integer.toString(n));
return createString(Integer.toString(n), USASCIIEncoding.INSTANCE);
}

@TruffleBoundary
@Specialization
public RubyBasicObject toS(long n, NotProvided base) {
return createString(Long.toString(n));
return createString(Long.toString(n), USASCIIEncoding.INSTANCE);
}

@TruffleBoundary
@@ -1184,7 +1185,7 @@ public RubyBasicObject toS(long n, int base) {
throw new RaiseException(getContext().getCoreLibrary().argumentErrorInvalidRadix(base, this));
}

return createString(Long.toString(n, base));
return createString(Long.toString(n, base), USASCIIEncoding.INSTANCE);
}

}
Original file line number Diff line number Diff line change
@@ -98,6 +98,21 @@ public int optionsNotInitialized(RubyRegexp regexp) {

}

@RubiniusPrimitive(name = "regexp_propagate_last_match")
public static abstract class RegexpPropagateLastMatchPrimitiveNode extends RubiniusPrimitiveNode {

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

@Specialization
public RubyBasicObject propagateLastMatch(RubyClass regexpClass) {
// TODO (nirvdrum 08-Jun-15): This method seems to exist just to fix Rubinius's broken frame-local scoping. This assertion needs to be verified, however.
return nil();
}

}

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