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

Commits on Feb 6, 2015

  1. Copy the full SHA
    a2f5e08 View commit details
  2. Copy the full SHA
    0e6a3a2 View commit details
Showing with 21 additions and 4 deletions.
  1. +0 −2 spec/truffle/tags/core/string/concat_tags.txt
  2. +21 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/concat_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
fails:String#concat converts the given argument to a String using to_str
fails:String#concat raises a RuntimeError when self is frozen
fails:String#concat taints self if other is tainted
fails:String#concat untrusts self if other is untrusted
fails:String#concat with Integer concatencates the argument interpreted as a codepoint
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.CreateCast;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
@@ -171,7 +174,11 @@ public Object compare(VirtualFrame frame, RubyString a, Object b) {
}

@CoreMethod(names = { "<<", "concat" }, required = 1)
public abstract static class ConcatNode extends CoreMethodNode {
@NodeChildren({
@NodeChild(value = "string"),
@NodeChild(value = "other")
})
public abstract static class ConcatNode extends RubyNode {

public ConcatNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -181,8 +188,20 @@ public ConcatNode(ConcatNode prev) {
super(prev);
}

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

@Specialization
public RubyString concat(RubyString string, RubyString other) {
notDesignedForCompilation();

if (string.isFrozen()) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(getContext().getCoreLibrary().frozenError("String", this));
}

string.getBytes().append(other.getBytes());
return string;
}
@@ -1076,7 +1095,7 @@ public abstract static class InsertNode extends CoreMethodNode {

public InsertNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
concatNode = StringNodesFactory.ConcatNodeFactory.create(context, sourceSection, new RubyNode[]{});
concatNode = StringNodesFactory.ConcatNodeFactory.create(context, sourceSection, null, null);
getIndexNode = StringNodesFactory.GetIndexNodeFactory.create(context, sourceSection, new RubyNode[]{});
}