Skip to content

Commit

Permalink
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/kernel/backtick_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:Kernel#` produces a String in the default external encoding
fails:Kernel#` sets $? to the exit status of the executed sub-process
fails:Kernel#` raises an Errno::ENOENT if the command is not executable
fails:Kernel.` tries to convert the given argument to String using #to_str
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@
import org.jruby.truffle.core.cast.NameToSymbolOrStringNodeGen;
import org.jruby.truffle.core.cast.TaintResultNode;
import org.jruby.truffle.core.cast.ToPathNodeGen;
import org.jruby.truffle.core.cast.ToStrNode;
import org.jruby.truffle.core.cast.ToStrNodeGen;
import org.jruby.truffle.core.encoding.EncodingOperations;
import org.jruby.truffle.core.format.BytesResult;
@@ -153,6 +154,17 @@ public abstract class KernelNodes {
public abstract static class BacktickNode extends CoreMethodArrayArgumentsNode {

@Child private CallDispatchHeadNode toHashNode;
@Child private ToStrNode toStrNode;

@Specialization(guards = "!isRubyString(command)")
public DynamicObject backtickCoerce(VirtualFrame frame, DynamicObject command) {
// TODO BJF Aug 4, 2016 Needs SafeStringValue here

This comment has been minimized.

Copy link
@eregon

eregon Aug 5, 2016

Member

It might be more convenient to define this as a primitive, and do the conversion in Ruby.

if (toStrNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
toStrNode = insert(ToStrNodeGen.create(getContext(), getSourceSection(), null));
}
return backtick(frame, toStrNode.executeToStr(frame, command));
}

@Specialization(guards = "isRubyString(command)")
public DynamicObject backtick(VirtualFrame frame, DynamicObject command) {

0 comments on commit 86cb695

Please sign in to comment.