Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 70f7bf627a13
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e5384d1ad412
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 24, 2015

  1. Copy the full SHA
    3b0bd45 View commit details
  2. Copy the full SHA
    e5384d1 View commit details
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ public ByteList format(double value) {
builder.append(".");
builder.append(zeroPadding);
}
} else if (zeroPadding != FormatDirective.DEFAULT) {
} else if (zeroPadding != FormatDirective.DEFAULT && zeroPadding != 0) {
builder.append("0");
builder.append(zeroPadding);
}
Original file line number Diff line number Diff line change
@@ -9,10 +9,13 @@
*/
package org.jruby.truffle.pack.nodes.type;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.pack.nodes.PackNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
@@ -24,6 +27,8 @@
})
public abstract class ToIntegerNode extends PackNode {

@Child private CallDispatchHeadNode integerNode;

public ToIntegerNode(RubyContext context) {
super(context);
}
@@ -50,4 +55,14 @@ public long toInteger(VirtualFrame frame, double value) {
return (long) value;
}

@Specialization(guards = {"!isInteger(value)", "!isLong(value)", "!isRubyBignum(value)"})
public Object toInteger(VirtualFrame frame, Object value) {
if (integerNode == null) {
CompilerDirectives.transferToInterpreter();
integerNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true));
}

return integerNode.call(frame, getContext().getCoreLibrary().getKernelModule(), "Integer", null, value);
}

}