Skip to content

Commit

Permalink
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/bignum/element_reference_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -450,6 +450,8 @@ public Object leftShift(DynamicObject a, int b) {
@CoreMethod(names = ">>", required = 1, lowerFixnumParameters = 0)
public abstract static class RightShiftNode extends BignumCoreMethodNode {

public abstract Object executeRightShift(VirtualFrame frame, DynamicObject a, Object b);

private final BranchProfile bLessThanZero = BranchProfile.create();

@Specialization
@@ -462,22 +464,26 @@ public Object rightShift(DynamicObject a, int b) {
}
}

@Specialization
public Object rightShift(DynamicObject a, long b) {
if (b > Integer.MAX_VALUE || b < Integer.MIN_VALUE) {
return 0;
} else {
return rightShift(a, (int) b);
}
}

@Specialization(guards = "isRubyBignum(b)")
public int rightShift(DynamicObject a, DynamicObject b) {
return 0;
}

@Specialization(guards = {"!isRubyBignum(b)", "!isInteger(b)"})
@Specialization(guards = {"!isRubyBignum(b)", "!isInteger(b)", "!isLong(b)"})
public Object rightShift(VirtualFrame frame,
DynamicObject a,
Object b,
@Cached("new()") SnippetNode snippetNode) {
int bInt = (int) snippetNode.execute(frame, "Rubinius::Type.coerce_to(y, Integer, :to_int)", "y", b);
if (bInt >= 0) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).shiftRight(bInt));
} else {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).shiftLeft(-bInt));
}
return executeRightShift(frame, a, snippetNode.execute(frame, "Rubinius::Type.coerce_to(y, Integer, :to_int)", "y", b));
}


1 comment on commit 808c0a8

@eregon
Copy link
Member

@eregon eregon commented on 808c0a8 Apr 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.