use mrb_int_mul_overflow()

This commit is contained in:
cremno
2016-05-10 19:09:38 +02:00
parent 6369374f79
commit 7453a5dfea
2 changed files with 10 additions and 28 deletions
+6 -16
View File
@@ -1862,25 +1862,15 @@ RETRY_TRY_BLOCK:
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):
{
mrb_value z;
mrb_int x, y, z;
z = mrb_fixnum_mul(mrb, regs[a], regs[a+1]);
switch (mrb_type(z)) {
case MRB_TT_FIXNUM:
{
SET_INT_VALUE(regs[a], mrb_fixnum(z));
}
break;
case MRB_TT_FLOAT:
{
SET_FLOAT_VALUE(mrb, regs[a], mrb_float(z));
}
break;
default:
/* cannot happen */
x = mrb_fixnum(regs[a]);
y = mrb_fixnum(regs[a+1]);
if (mrb_int_mul_overflow(x, y, &z)) {
SET_FLOAT_VALUE(mrb, regs[a], (mrb_float)x * (mrb_float)y);
break;
}
SET_INT_VALUE(regs[a], z);
}
break;
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FLOAT):