Skip to content

Commit

Permalink
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
Original file line number Diff line number Diff line change
@@ -66,6 +66,11 @@ public double add(double a, DynamicObject b) {
return a + Layouts.BIGNUM.getValue(b).doubleValue();
}

// TODO (pitr 14-Sep-2015): all coerces should be replaced with a CallDispatchHeadNodes to speed up things like `5 + rational`
@Specialization(guards = "!isRubyBignum(b)")
public Object addCoerced(VirtualFrame frame, double a, DynamicObject b) {
return ruby(frame, "redo_coerced :+, b", "b", b);
}
}

@CoreMethod(names = "-", required = 1)
@@ -247,6 +252,11 @@ public double mod(double a, DynamicObject b) {
return mod(a, Layouts.BIGNUM.getValue(b).doubleValue());
}

@Specialization(guards = "!isRubyBignum(b)")
public Object modCoerced(VirtualFrame frame, double a, DynamicObject b) {
return ruby(frame, "redo_coerced :mod, b", "b", b);
}

}

@CoreMethod(names = "divmod", required = 1)
@@ -274,6 +284,11 @@ public DynamicObject divMod(double a, DynamicObject b) {
return divModNode.execute(a, Layouts.BIGNUM.getValue(b));
}

@Specialization(guards = "!isRubyBignum(b)")
public Object divModCoerced(VirtualFrame frame, double a, DynamicObject b) {
return ruby(frame, "redo_coerced :divmod, b", "b", b);
}

}

@CoreMethod(names = "<", required = 1)

0 comments on commit 8834164

Please sign in to comment.