summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index dc6c8f5..1a8f325 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1776,10 +1776,14 @@ opt_eq_func(VALUE recv, VALUE obj, IC ic)
BASIC_OP_UNREDEFINED_P(BOP_EQ, FIXNUM_REDEFINED_OP_FLAG)) {
return (recv == obj) ? Qtrue : Qfalse;
}
+ else if (FLONUM_2_P(recv, obj) &&
+ BASIC_OP_UNREDEFINED_P(BOP_EQ, FLOAT_REDEFINED_OP_FLAG)) {
+ return (recv == obj) ? Qtrue : Qfalse;
+ }
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
if (HEAP_CLASS_OF(recv) == rb_cFloat &&
HEAP_CLASS_OF(obj) == rb_cFloat &&
- BASIC_OP_UNREDEFINED_P(BOP_EQ, FLOAT_REDEFINED_OP_FLAG)) {
+ BASIC_OP_UNREDEFINED_P(BOP_EQ, FLOAT_REDEFINED_OP_FLAG)) {
double a = RFLOAT_VALUE(recv);
double b = RFLOAT_VALUE(obj);
@@ -1865,3 +1869,37 @@ check_match(VALUE pattern, VALUE target, enum vm_check_match_type type)
}
}
+
+#if defined(_MSC_VER) && _MSC_VER < 1300
+#define CHECK_CMP_NAN(a, b) if (isnan(a) || isnan(b)) return Qfalse;
+#else
+#define CHECK_CMP_NAN(a, b)
+#endif
+
+static inline VALUE
+double_cmp_lt(double a, double b)
+{
+ CHECK_CMP_NAN(a, b);
+ return a < b ? Qtrue : Qfalse;
+}
+
+static inline VALUE
+double_cmp_le(double a, double b)
+{
+ CHECK_CMP_NAN(a, b);
+ return a <= b ? Qtrue : Qfalse;
+}
+
+static inline VALUE
+double_cmp_gt(double a, double b)
+{
+ CHECK_CMP_NAN(a, b);
+ return a > b ? Qtrue : Qfalse;
+}
+
+static inline VALUE
+double_cmp_ge(double a, double b)
+{
+ CHECK_CMP_NAN(a, b);
+ return a >= b ? Qtrue : Qfalse;
+}