-
-
Notifications
You must be signed in to change notification settings - Fork 921
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1672,6 +1672,7 @@ public RubyString rstrip(RubyString string) { | |
} | ||
|
||
@CoreMethod(names = "dump", taintFromSelf = true) | ||
@ImportGuards(StringGuards.class) | ||
public abstract static class DumpNode extends CoreMethodNode { | ||
|
||
public DumpNode(RubyContext context, SourceSection sourceSection) { | ||
|
@@ -1682,13 +1683,41 @@ public DumpNode(DumpNode prev) { | |
super(prev); | ||
} | ||
|
||
@Specialization | ||
public RubyString rstrip(RubyString string) { | ||
notDesignedForCompilation(); | ||
@Specialization(guards = "isAsciiCompatible") | ||
public RubyString dumpAsciiCompatible(RubyString string) { | ||
// Taken from org.jruby.RubyString#dump | ||
|
||
ByteList outputBytes = dumpCommon(string); | ||
|
||
final RubyString result = getContext().makeString(string.getLogicalClass(), outputBytes); | ||
result.getByteList().setEncoding(string.getByteList().getEncoding()); | ||
result.setCodeRange(StringSupport.CR_7BIT); | ||
|
||
return result; | ||
} | ||
|
||
@Specialization(guards = "!isAsciiCompatible") | ||
public RubyString dump(RubyString string) { | ||
// Taken from org.jruby.RubyString#dump | ||
|
||
ByteList outputBytes = dumpCommon(string); | ||
|
||
outputBytes.append(".force_encoding(\"".getBytes()); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nirvdrum
Author
Contributor
|
||
outputBytes.append(string.getByteList().getEncoding().getName()); | ||
outputBytes.append((byte) '"'); | ||
outputBytes.append((byte) ')'); | ||
|
||
return string.dump(); | ||
final RubyString result = getContext().makeString(string.getLogicalClass(), outputBytes); | ||
result.getByteList().setEncoding(ASCIIEncoding.INSTANCE); | ||
result.setCodeRange(StringSupport.CR_7BIT); | ||
|
||
return result; | ||
} | ||
|
||
@TruffleBoundary | ||
private ByteList dumpCommon(RubyString string) { | ||
return StringSupport.dumpCommon(getContext().getRuntime(), string.getByteList()); | ||
} | ||
} | ||
|
||
@CoreMethod(names = "scan", required = 1, needsBlock = true, taintFromParameters = 0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi @nirvdrum
I think I'm seeing a findbugs error around here