Skip to content

Commit

Permalink
[Truffle] Removing Fixnum#/ Rational and Complex specializations
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed Apr 6, 2015
1 parent dce0852 commit cc501a6
Showing 1 changed file with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -569,36 +569,12 @@ public int div(@SuppressWarnings("unused") long a, @SuppressWarnings("unused") R
return 0;
}

@Specialization(guards = "isRational(arguments[1])")
public Object div(VirtualFrame frame, int a, RubyBasicObject b) {
if (rationalConvertNode == null) {
CompilerDirectives.transferToInterpreter();
rationalConvertNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true));
rationalDivNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
}

final Object aRational = rationalConvertNode.call(frame, getContext().getCoreLibrary().getRationalClass(), "convert", null, a, 1);

return rationalDivNode.call(frame, aRational, "/", null, b);
}

@Specialization(guards = "isComplex(arguments[1])")
public Object divComplex(VirtualFrame frame, int a, RubyBasicObject b) {
return ruby(frame, "Complex(a) / b", "a", a, "b", b);
}

@Specialization(guards = "isComplex(arguments[1])")
public Object divComplex(VirtualFrame frame, long a, RubyBasicObject b) {
return ruby(frame, "Complex(a) / b", "a", a, "b", b);
}


@Specialization(guards = {"!isComplex(arguments[1])", "!isRational(arguments[1])", "!isRubyBignum(arguments[1])"})
@Specialization(guards = {"!isRubyBignum(arguments[1])"})
public Object divFallback(VirtualFrame frame, long a, RubyBasicObject b) {
return ruby(frame, "redo_coerced :/, o", "o", b);
}

@Specialization(guards = {"!isComplex(arguments[1])", "!isRational(arguments[1])", "!isRubyBignum(arguments[1])"})
@Specialization(guards = {"!isRubyBignum(arguments[1])"})
public Object divFallback(VirtualFrame frame, int a, RubyBasicObject b) {
return ruby(frame, "redo_coerced :/, o", "o", b);
}
Expand Down

0 comments on commit cc501a6

Please sign in to comment.