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: a62f56f407a2
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f69ecf97bf00
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Dec 27, 2015

  1. Copy the full SHA
    dbacbc9 View commit details
  2. Merge pull request #3562 from ehsanul/truffle-bignum-fixes

    [Truffle] implement Bignum#~ (complement) and complete Bignum#divmod
    eregon committed Dec 27, 2015
    Copy the full SHA
    f69ecf9 View commit details
1 change: 0 additions & 1 deletion spec/truffle/tags/core/bignum/complement_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/bignum/divmod_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -378,6 +378,20 @@ public Object greaterCoerced(VirtualFrame frame, DynamicObject a, Object b) {
}
}

@CoreMethod(names = "~")
public abstract static class ComplementNode extends BignumCoreMethodNode {

public ComplementNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object complement(DynamicObject value) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(value).not());
}

}

@CoreMethod(names = "&", required = 1)
public abstract static class BitAndNode extends BignumCoreMethodNode {

@@ -554,6 +568,11 @@ public DynamicObject divMod(DynamicObject a, long b) {
return divModNode.execute(Layouts.BIGNUM.getValue(a), b);
}

@Specialization
public DynamicObject divMod(DynamicObject a, double b) {
return divModNode.execute(Layouts.BIGNUM.getValue(a), b);
}

@Specialization(guards = "isRubyBignum(b)")
public DynamicObject divMod(DynamicObject a, DynamicObject b) {
return divModNode.execute(Layouts.BIGNUM.getValue(a), Layouts.BIGNUM.getValue(b));
Original file line number Diff line number Diff line change
@@ -59,6 +59,10 @@ public DynamicObject execute(BigInteger a, BigInteger b) {
return divMod(a, b);
}

public DynamicObject execute(BigInteger a, double b) {
return divMod(a.doubleValue(), b);
}

public DynamicObject execute(double a, long b) {
return divMod(a, b);
}