Skip to content

Commit

Permalink
Showing 2 changed files with 6 additions and 10 deletions.
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/string/modulo_tags.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
fails:String#% behaves as if calling Kernel#Float for %e arguments, when the passed argument does not respond to #to_ary
fails:String#% behaves as if calling Kernel#Float for %e arguments, when the passed argument is hexadecimal string
fails:String#% behaves as if calling Kernel#Float for %E arguments, when the passed argument does not respond to #to_ary
fails:String#% behaves as if calling Kernel#Float for %E arguments, when the passed argument is hexadecimal string
fails:String#% behaves as if calling Kernel#Float for %f arguments, when the passed argument does not respond to #to_ary
fails:String#% behaves as if calling Kernel#Float for %f arguments, when the passed argument is hexadecimal string
fails:String#% behaves as if calling Kernel#Float for %g arguments, when the passed argument does not respond to #to_ary
fails:String#% behaves as if calling Kernel#Float for %g arguments, when the passed argument is hexadecimal string
fails:String#% behaves as if calling Kernel#Float for %G arguments, when the passed argument does not respond to #to_ary
fails:String#% behaves as if calling Kernel#Float for %G arguments, when the passed argument is hexadecimal string
Original file line number Diff line number Diff line change
@@ -14,26 +14,27 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.cast.ToFNode;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.language.dispatch.DispatchHeadNodeFactory;

@NodeChild(value = "value", type = FormatNode.class)
public abstract class ToDoubleWithCoercionNode extends FormatNode {

@Child private ToFNode toFNode;
@Child private CallDispatchHeadNode floatNode;

public ToDoubleWithCoercionNode(RubyContext context) {
super(context);
}

@Specialization
public Object toDouble(VirtualFrame frame, Object value) {
if (toFNode == null) {
if (floatNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
toFNode = insert(ToFNode.create());
floatNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true));
}

return toFNode.doDouble(frame, value);
return floatNode.call(frame, getContext().getCoreLibrary().getKernelModule(), "Float", value);
}

}

0 comments on commit 6b3b308

Please sign in to comment.