Skip to content

Commit

Permalink
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions spec/truffle/tags/core/string/encode_tags.txt
Original file line number Diff line number Diff line change
@@ -80,3 +80,4 @@ fails:String#encode! when passed no options returns self for a ASCII-only String
fails:String#encode! when passed options returns self for ASCII-only String when Encoding.default_internal is nil
fails:String#encode! when passed to encoding returns self
fails:String#encode! when passed to, from returns self
fails:String#encode raises ArgumentError if the value of the :xml option is not :text or :attr
Original file line number Diff line number Diff line change
@@ -808,7 +808,7 @@ public boolean empty(RubyString string) {
}
}

@CoreMethod(names = "encode", required = 1)
@CoreMethod(names = "encode", required = 1, optional = 1)
public abstract static class EncodeNode extends CoreMethodNode {

@Child private ToStrNode toStrNode;
@@ -822,7 +822,7 @@ public EncodeNode(EncodeNode prev) {
}

@Specialization
public RubyString encode(RubyString string, RubyString encoding) {
public RubyString encode(RubyString string, RubyString encoding, @SuppressWarnings("unused") UndefinedPlaceholder options) {
notDesignedForCompilation();

final org.jruby.RubyString jrubyString = getContext().toJRuby(string);
@@ -833,7 +833,15 @@ public RubyString encode(RubyString string, RubyString encoding) {
}

@Specialization
public RubyString encode(RubyString string, RubyEncoding encoding) {
public RubyString encode(RubyString string, RubyString encoding, @SuppressWarnings("unused") RubyHash options) {
notDesignedForCompilation();

// TODO (nirvdrum 20-Feb-15) We need to do something with the options hash. I'm stubbing this out just to get the jUnit mspec formatter running.
return encode(string, encoding, UndefinedPlaceholder.INSTANCE);
}

@Specialization
public RubyString encode(RubyString string, RubyEncoding encoding, @SuppressWarnings("unused") UndefinedPlaceholder options) {
notDesignedForCompilation();

final org.jruby.RubyString jrubyString = getContext().toJRuby(string);
@@ -844,15 +852,15 @@ public RubyString encode(RubyString string, RubyEncoding encoding) {
}

@Specialization(guards = { "!isRubyString(arguments[1])", "!isRubyEncoding(arguments[1])" })
public RubyString encode(VirtualFrame frame, RubyString string, Object encoding) {
public RubyString encode(VirtualFrame frame, RubyString string, Object encoding, UndefinedPlaceholder options) {
notDesignedForCompilation();

if (toStrNode == null) {
CompilerDirectives.transferToInterpreter();
toStrNode = insert(ToStrNodeFactory.create(getContext(), getSourceSection(), null));
}

return encode(string, toStrNode.executeRubyString(frame, encoding));
return encode(string, toStrNode.executeRubyString(frame, encoding), options);
}
}

0 comments on commit cf522e4

Please sign in to comment.