Skip to content

Commit

Permalink
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyBignum;

@NodeChild(value = "child", type = RubyNode.class)
@@ -63,10 +64,18 @@ public Object coerceDouble(VirtualFrame frame, double value) {
return floatToIntNode.executeToI(frame, value);
}

@Specialization
public Object coerceBoolean(VirtualFrame frame, boolean value) {
return coerceObject(frame, value);
}

@Specialization(guards = "!isRubyBignum")
public Object coerceObject(VirtualFrame frame, Object object) {
notDesignedForCompilation();
public Object coerceBasicObject(VirtualFrame frame, RubyBasicObject object) {
return coerceObject(frame, object);
}

@CompilerDirectives.TruffleBoundary
private Object coerceObject(VirtualFrame frame, Object object) {
if (toIntNode == null) {
CompilerDirectives.transferToInterpreter();
toIntNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));

0 comments on commit 6a985a3

Please sign in to comment.