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

Commits on Apr 1, 2015

  1. Copy the full SHA
    d0a2ba2 View commit details
  2. Copy the full SHA
    d31c337 View commit details
  3. Copy the full SHA
    d481df2 View commit details
Showing with 58 additions and 23 deletions.
  1. +0 −16 spec/truffle/tags/core/string/tr_s_tags.txt
  2. +58 −7 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
16 changes: 0 additions & 16 deletions spec/truffle/tags/core/string/tr_s_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -2026,15 +2026,15 @@ public static boolean reverseIsEqualToSelf(RubyString string) {
@NodeChild(value = "fromStr"),
@NodeChild(value = "toStr")
})
public abstract static class TrNode extends RubyNode {
public abstract static class TrBangNode extends RubyNode {

@Child private DeleteBangNode deleteBangNode;

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

public TrNode(TrNode prev) {
public TrBangNode(TrBangNode prev) {
super(prev);
deleteBangNode = prev.deleteBangNode;
}
@@ -2048,7 +2048,7 @@ public TrNode(TrNode prev) {
}

@Specialization
public Object tr(VirtualFrame frame, RubyString self, RubyString fromStr, RubyString toStr) {
public Object trBang(VirtualFrame frame, RubyString self, RubyString fromStr, RubyString toStr) {
if (self.getByteList().getRealSize() == 0) {
return nil();
}
@@ -2062,13 +2062,53 @@ public Object tr(VirtualFrame frame, RubyString self, RubyString fromStr, RubySt
return deleteBangNode.deleteBang(frame, self, fromStr);
}

final CodeRangeable ret = StringSupport.trTransHelper(getContext().getRuntime(), self, fromStr, toStr, false);
return StringNodesHelper.trTransHelper(getContext(), self, fromStr, toStr, false);
}
}

if (ret == null) {
@CoreMethod(names = "tr_s!", required = 2, raiseIfFrozenSelf = true)
@NodeChildren({
@NodeChild(value = "self"),
@NodeChild(value = "fromStr"),
@NodeChild(value = "toStr")
})
public abstract static class TrSBangNode extends RubyNode {

@Child private DeleteBangNode deleteBangNode;

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

public TrSBangNode(TrSBangNode prev) {
super(prev);
deleteBangNode = prev.deleteBangNode;
}

@CreateCast("fromStr") public RubyNode coerceFromStrToString(RubyNode fromStr) {
return ToStrNodeFactory.create(getContext(), getSourceSection(), fromStr);
}

@CreateCast("toStr") public RubyNode coerceToStrToString(RubyNode toStr) {
return ToStrNodeFactory.create(getContext(), getSourceSection(), toStr);
}

@Specialization
public Object trSBang(VirtualFrame frame, RubyString self, RubyString fromStr, RubyString toStr) {
if (self.getByteList().getRealSize() == 0) {
return nil();
}

return ret;
if (toStr.getByteList().getRealSize() == 0) {
if (deleteBangNode == null) {
CompilerDirectives.transferToInterpreter();
deleteBangNode = insert(StringNodesFactory.DeleteBangNodeFactory.create(getContext(), getSourceSection(), new RubyNode[] {}));
}

return deleteBangNode.deleteBang(frame, self, fromStr);
}

return StringNodesHelper.trTransHelper(getContext(), self, fromStr, toStr, true);
}
}

@@ -2322,6 +2362,17 @@ public static int checkIndex(RubyString string, int index, RubyNode node) {
public static void replaceInternal(RubyString string, int start, int length, RubyString replacement) {
StringSupport.replaceInternal19(start, length, string, replacement);
}

@TruffleBoundary
private static Object trTransHelper(RubyContext context, RubyString self, RubyString fromStr, RubyString toStr, boolean sFlag) {
final CodeRangeable ret = StringSupport.trTransHelper(context.getRuntime(), self, fromStr, toStr, sFlag);

if (ret == null) {
return context.getCoreLibrary().getNilObject();
}

return ret;
}
}

}