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: 6b5b77ebd0c5
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0dced16aac21
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Mar 10, 2016

  1. Copy the full SHA
    6af566b View commit details
  2. Copy the full SHA
    1c3fb7d View commit details
  3. Copy the full SHA
    0dced16 View commit details
Showing with 17 additions and 22 deletions.
  1. +17 −22 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
Original file line number Diff line number Diff line change
@@ -183,8 +183,8 @@ public MulNode(RubyContext context, SourceSection sourceSection) {
public abstract DynamicObject executeInt(VirtualFrame frame, DynamicObject string, int times);

@Specialization(guards = "times < 0")
@TruffleBoundary
public DynamicObject multiplyTimesNegative(DynamicObject string, int times) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().argumentError("negative argument", this));
}

@@ -289,11 +289,9 @@ public DynamicObject multiply(DynamicObject string, int times) {
}

@Specialization(guards = "isRubyBignum(times)")
@TruffleBoundary
public DynamicObject multiply(DynamicObject string, DynamicObject times) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(
coreLibrary().rangeError("bignum too big to convert into `long'", this));
throw new RaiseException(coreLibrary().rangeError("bignum too big to convert into `long'", this));
}

@Specialization(guards = { "!isRubyBignum(times)", "!isInteger(times)" })
@@ -378,9 +376,8 @@ public int compare(DynamicObject a, DynamicObject b) {
}

@Specialization(guards = "!isRubyString(b)")
@TruffleBoundary
public Object compare(VirtualFrame frame, DynamicObject a, Object b) {
CompilerDirectives.transferToInterpreter();

if (respondToToStrNode == null) {
CompilerDirectives.transferToInterpreter();
respondToToStrNode = insert(KernelNodesFactory.RespondToNodeFactory.create(getContext(), getSourceSection(), null, null, null));
@@ -475,7 +472,7 @@ public Object concatString(DynamicObject string, DynamicObject other) {
}

@Specialization(guards = "!isRubyString(other)")
public Object concat(VirtualFrame frame, DynamicObject string, Object other) {
public Object concat(DynamicObject string, Object other) {
return ruby("string.concat_internal(other)", "string", string, "other", other);
}
}
@@ -586,11 +583,11 @@ public Object slice(VirtualFrame frame, DynamicObject string, Object start, Obje

@Specialization(guards = {"isRubyRegexp(regexp)", "wasNotProvided(capture) || isRubiniusUndefined(capture)"})
public Object slice1(VirtualFrame frame, DynamicObject string, DynamicObject regexp, Object capture) {
return sliceCapture(frame, string, regexp, 0);
return sliceCapture(string, regexp, 0);
}

@Specialization(guards = {"isRubyRegexp(regexp)", "wasProvided(capture)"})
public Object sliceCapture(VirtualFrame frame, DynamicObject string, DynamicObject regexp, Object capture) {
public Object sliceCapture(DynamicObject string, DynamicObject regexp, Object capture) {
// Extracted from Rubinius's definition of String#[].
return ruby("match, str = subpattern(index, other); Regexp.last_match = match; str", "index", regexp, "other", capture);
}
@@ -784,7 +781,7 @@ public ChopBangNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization(guards = "isEmpty(string)")
public DynamicObject chopBangEmpty(VirtualFrame frame, DynamicObject string) {
public DynamicObject chopBangEmpty(DynamicObject string) {
return nil();
}

@@ -934,7 +931,7 @@ public DeleteBangNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization(guards = "isEmpty(string)")
public DynamicObject deleteBangEmpty(VirtualFrame frame, DynamicObject string, Object... args) {
public DynamicObject deleteBangEmpty(DynamicObject string, Object... args) {
return nil();
}

@@ -1880,8 +1877,6 @@ public SizeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract int executeInteger(VirtualFrame frame, DynamicObject string);

@Specialization
public int size(DynamicObject string) {
return rope(string).characterLength();
@@ -2082,7 +2077,7 @@ public Object sum(VirtualFrame frame, DynamicObject string, NotProvided bits) {
}

@Specialization(guards = { "!isInteger(bits)", "!isLong(bits)", "wasProvided(bits)" })
public Object sum(VirtualFrame frame, DynamicObject string, Object bits) {
public Object sum(DynamicObject string, Object bits) {
return ruby("sum Rubinius::Type.coerce_to(bits, Fixnum, :to_int)", "bits", bits);
}

@@ -2124,7 +2119,7 @@ public DynamicObject toS(DynamicObject string) {
}

@Specialization(guards = "isStringSubclass(string)")
public Object toSOnSubclass(VirtualFrame frame, DynamicObject string) {
public Object toSOnSubclass(DynamicObject string) {
return ruby("''.replace(self)", "self", string);
}

@@ -2240,7 +2235,7 @@ public TrBangNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization(guards = "isEmpty(self)")
public Object trBangEmpty(VirtualFrame frame, DynamicObject self, DynamicObject fromStr, DynamicObject toStr) {
public Object trBangEmpty(DynamicObject self, DynamicObject fromStr, DynamicObject toStr) {
return nil();
}

@@ -2409,27 +2404,27 @@ private DynamicObject finishUnpack(Rope format, PackResult result) {
}

@Specialization
public Object unpack(VirtualFrame frame, DynamicObject array, boolean format) {
public Object unpack(DynamicObject array, boolean format) {
return ruby("raise TypeError");
}

@Specialization
public Object unpack(VirtualFrame frame, DynamicObject array, int format) {
public Object unpack(DynamicObject array, int format) {
return ruby("raise TypeError");
}

@Specialization
public Object unpack(VirtualFrame frame, DynamicObject array, long format) {
public Object unpack(DynamicObject array, long format) {
return ruby("raise TypeError");
}

@Specialization(guards = "isNil(format)")
public Object unpackNil(VirtualFrame frame, DynamicObject array, Object format) {
public Object unpackNil(DynamicObject array, Object format) {
return ruby("raise TypeError");
}

@Specialization(guards = {"!isRubyString(format)", "!isBoolean(format)", "!isInteger(format)", "!isLong(format)", "!isNil(format)"})
public Object unpack(VirtualFrame frame, DynamicObject array, Object format) {
public Object unpack(DynamicObject array, Object format) {
return ruby("unpack(format.to_str)", "format", format);
}