Skip to content

Commit

Permalink
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/replace_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1595,7 +1595,11 @@ public int ord(RubyString string) {
}

@CoreMethod(names = "replace", required = 1, raiseIfFrozenSelf = true, taintFromParameters = 0)
public abstract static class ReplaceNode extends CoreMethodNode {
@NodeChildren({
@NodeChild(value = "string"),
@NodeChild(value = "other")
})
public abstract static class ReplaceNode extends RubyNode {

public ReplaceNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -1605,15 +1609,18 @@ public ReplaceNode(ReplaceNode prev) {
super(prev);
}

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

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

if (string == other) {
return string;
}

string.getByteList().replace(other.getByteList().bytes());
string.getByteList().setEncoding(other.getByteList().getEncoding());
string.setCodeRange(other.getCodeRange());

return string;

0 comments on commit 48072b4

Please sign in to comment.