summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-05-26 21:27:16 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-05-26 21:27:16 +0900
commit7b8ae1b8b64c281d983723d2c127f5713ad6e640 (patch)
tree11f5833e6d9f3c2618cd192cd2e651b5eebba652 /src
parent6557ee938a5404b31b064f08c58bb54dfc0ac468 (diff)
parentec3a5f33ba8b52fc9d5ee21cdb0a689622608f98 (diff)
downloadmruby-7b8ae1b8b64c281d983723d2c127f5713ad6e640.tar.gz
mruby-7b8ae1b8b64c281d983723d2c127f5713ad6e640.zip
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c8
-rw-r--r--src/etc.c22
-rw-r--r--src/gc.c8
-rw-r--r--src/kernel.c2
-rw-r--r--src/load.c2
-rw-r--r--src/numeric.c50
-rw-r--r--src/object.c4
-rw-r--r--src/string.c2
-rw-r--r--src/vm.c122
9 files changed, 169 insertions, 51 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 581d13280..cfbbe7286 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -1901,7 +1901,7 @@ codegen(codegen_scope *s, node *tree, int val)
i = readint_mrb_int(s, p, base, FALSE, &overflow);
if (overflow) {
double f = readint_float(s, p, base);
- int off = new_lit(s, mrb_float_value(f));
+ int off = new_lit(s, mrb_float_value(s->mrb, f));
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
}
@@ -1923,7 +1923,7 @@ codegen(codegen_scope *s, node *tree, int val)
if (val) {
char *p = (char*)tree;
mrb_float f = str_to_mrb_float(p);
- int off = new_lit(s, mrb_float_value(f));
+ int off = new_lit(s, mrb_float_value(s->mrb, f));
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
push();
@@ -1939,7 +1939,7 @@ codegen(codegen_scope *s, node *tree, int val)
{
char *p = (char*)tree;
mrb_float f = str_to_mrb_float(p);
- int off = new_lit(s, mrb_float_value(-f));
+ int off = new_lit(s, mrb_float_value(s->mrb, -f));
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
push();
@@ -1957,7 +1957,7 @@ codegen(codegen_scope *s, node *tree, int val)
i = readint_mrb_int(s, p, base, TRUE, &overflow);
if (overflow) {
double f = readint_float(s, p, base);
- int off = new_lit(s, mrb_float_value(-f));
+ int off = new_lit(s, mrb_float_value(s->mrb, -f));
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
}
diff --git a/src/etc.c b/src/etc.c
index f2ff34fec..2aee0f0f7 100644
--- a/src/etc.c
+++ b/src/etc.c
@@ -180,3 +180,25 @@ mrb_obj_id(mrb_value obj)
}
}
+#ifdef MRB_WORD_BOXING
+mrb_value
+mrb_float_value(mrb_state *mrb, mrb_float f)
+{
+ mrb_value v;
+
+ v.value.p = mrb_obj_alloc(mrb, MRB_TT_FLOAT, mrb->float_class);
+ v.value.fp->f = f;
+ return v;
+}
+
+mrb_value
+mrb_voidp_value(mrb_state *mrb, void *p)
+{
+ mrb_value v;
+
+ v.value.p = mrb_obj_alloc(mrb, MRB_TT_VOIDP, mrb->object_class);
+ v.value.vp->p = p;
+ return v;
+}
+#endif /* MRB_WORD_BOXING */
+
diff --git a/src/gc.c b/src/gc.c
index 00ddadffc..6419726eb 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -530,10 +530,16 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
case MRB_TT_TRUE:
case MRB_TT_FIXNUM:
case MRB_TT_SYMBOL:
- case MRB_TT_FLOAT:
/* cannot happen */
return;
+ case MRB_TT_FLOAT:
+#ifdef MRB_WORD_BOXING
+ break;
+#else
+ return;
+#endif
+
case MRB_TT_OBJECT:
mrb_gc_free_iv(mrb, (struct RObject*)obj);
break;
diff --git a/src/kernel.c b/src/kernel.c
index af4806378..0fe374e73 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -894,7 +894,7 @@ mrb_f_raise(mrb_state *mrb, mrb_value self)
/* fall through */
default:
exc = mrb_make_exception(mrb, argc, a);
- mrb_obj_iv_set(mrb, mrb_obj_ptr(exc), mrb_intern2(mrb, "lastpc", 6), mrb_voidp_value(mrb->c->ci->pc));
+ mrb_obj_iv_set(mrb, mrb_obj_ptr(exc), mrb_intern2(mrb, "lastpc", 6), mrb_voidp_value(mrb, mrb->c->ci->pc));
mrb_exc_raise(mrb, exc);
break;
}
diff --git a/src/load.c b/src/load.c
index 81d47858a..62010e425 100644
--- a/src/load.c
+++ b/src/load.c
@@ -130,7 +130,7 @@ read_rite_irep_record(mrb_state *mrb, const uint8_t *bin, uint32_t *len)
break;
case MRB_TT_FLOAT:
- irep->pool[i] = mrb_float_value(mrb_str_to_dbl(mrb, s, FALSE));
+ irep->pool[i] = mrb_float_value(mrb, mrb_str_to_dbl(mrb, s, FALSE));
break;
case MRB_TT_STRING:
diff --git a/src/numeric.c b/src/numeric.c
index 14b4929e0..6b118dfb4 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -65,7 +65,7 @@ num_uplus(mrb_state *mrb, mrb_value num)
static mrb_value
num_uminus(mrb_state *mrb, mrb_value num)
{
- return mrb_float_value((mrb_float)0 - mrb_to_flo(mrb, num));
+ return mrb_float_value(mrb, (mrb_float)0 - mrb_to_flo(mrb, num));
}
static mrb_value
@@ -95,7 +95,7 @@ num_pow(mrb_state *mrb, mrb_value x)
d = pow(mrb_to_flo(mrb, x), mrb_to_flo(mrb, y));
if (both_int && FIXABLE(d))
return mrb_fixnum_value((mrb_int)d);
- return mrb_float_value(d);
+ return mrb_float_value(mrb, d);
}
/* 15.2.8.3.4 */
@@ -112,7 +112,7 @@ num_pow(mrb_state *mrb, mrb_value x)
mrb_value
mrb_num_div(mrb_state *mrb, mrb_value x, mrb_value y)
{
- return mrb_float_value(mrb_to_flo(mrb, x) / mrb_to_flo(mrb, y));
+ return mrb_float_value(mrb, mrb_to_flo(mrb, x) / mrb_to_flo(mrb, y));
}
/* 15.2.9.3.19(x) */
@@ -129,7 +129,7 @@ num_div(mrb_state *mrb, mrb_value x)
mrb_float y;
mrb_get_args(mrb, "f", &y);
- return mrb_float_value(mrb_to_flo(mrb, x) / y);
+ return mrb_float_value(mrb, mrb_to_flo(mrb, x) / y);
}
/*
@@ -297,7 +297,7 @@ flo_minus(mrb_state *mrb, mrb_value x)
mrb_value y;
mrb_get_args(mrb, "o", &y);
- return mrb_float_value(mrb_float(x) - mrb_to_flo(mrb, y));
+ return mrb_float_value(mrb, mrb_float(x) - mrb_to_flo(mrb, y));
}
/* 15.2.9.3.3 */
@@ -315,7 +315,7 @@ flo_mul(mrb_state *mrb, mrb_value x)
mrb_value y;
mrb_get_args(mrb, "o", &y);
- return mrb_float_value(mrb_float(x) * mrb_to_flo(mrb, y));
+ return mrb_float_value(mrb, mrb_float(x) * mrb_to_flo(mrb, y));
}
static void
@@ -366,7 +366,7 @@ flo_mod(mrb_state *mrb, mrb_value x)
fy = mrb_to_flo(mrb, y);
flodivmod(mrb, mrb_float(x), fy, 0, &mod);
- return mrb_float_value(mod);
+ return mrb_float_value(mrb, mod);
}
/* 15.2.8.3.16 */
@@ -545,7 +545,7 @@ flo_floor(mrb_state *mrb, mrb_value num)
mrb_float f = floor(mrb_float(num));
if (!FIXABLE(f)) {
- return mrb_float_value(f);
+ return mrb_float_value(mrb, f);
}
return mrb_fixnum_value((mrb_int)f);
}
@@ -570,7 +570,7 @@ flo_ceil(mrb_state *mrb, mrb_value num)
mrb_float f = ceil(mrb_float(num));
if (!FIXABLE(f)) {
- return mrb_float_value(f);
+ return mrb_float_value(mrb, f);
}
return mrb_fixnum_value((mrb_int)f);
}
@@ -642,7 +642,7 @@ flo_round(mrb_state *mrb, mrb_value num)
if (ndigits < 0) number *= f;
else number /= f;
}
- if (ndigits > 0) return mrb_float_value(number);
+ if (ndigits > 0) return mrb_float_value(mrb, number);
return mrb_fixnum_value((mrb_int)number);
}
@@ -666,7 +666,7 @@ flo_truncate(mrb_state *mrb, mrb_value num)
if (f < 0.0) f = ceil(f);
if (!FIXABLE(f)) {
- return mrb_float_value(f);
+ return mrb_float_value(mrb, f);
}
return mrb_fixnum_value((mrb_int)f);
}
@@ -750,11 +750,11 @@ mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y)
return mrb_fixnum_value(a*b);
c = a * b;
if (a != 0 && c/a != b) {
- return mrb_float_value((mrb_float)a*(mrb_float)b);
+ return mrb_float_value(mrb, (mrb_float)a*(mrb_float)b);
}
return mrb_fixnum_value(c);;
}
- return mrb_float_value((mrb_float)a * mrb_to_flo(mrb, y));
+ return mrb_float_value(mrb, (mrb_float)a * mrb_to_flo(mrb, y));
}
/* 15.2.8.3.3 */
@@ -826,7 +826,7 @@ fix_mod(mrb_state *mrb, mrb_value x)
mrb_int mod;
if (mrb_fixnum(y) == 0) {
- return mrb_float_value(str_to_mrb_float("nan"));
+ return mrb_float_value(mrb, str_to_mrb_float("nan"));
}
fixdivmod(mrb, a, mrb_fixnum(y), 0, &mod);
return mrb_fixnum_value(mod);
@@ -835,7 +835,7 @@ fix_mod(mrb_state *mrb, mrb_value x)
mrb_float mod;
flodivmod(mrb, (mrb_float)a, mrb_to_flo(mrb, y), 0, &mod);
- return mrb_float_value(mod);
+ return mrb_float_value(mrb, mod);
}
}
@@ -856,8 +856,8 @@ fix_divmod(mrb_state *mrb, mrb_value x)
mrb_int div, mod;
if (mrb_fixnum(y) == 0) {
- return mrb_assoc_new(mrb, mrb_float_value(str_to_mrb_float("inf")),
- mrb_float_value(str_to_mrb_float("nan")));
+ return mrb_assoc_new(mrb, mrb_float_value(mrb, str_to_mrb_float("inf")),
+ mrb_float_value(mrb, str_to_mrb_float("nan")));
}
fixdivmod(mrb, mrb_fixnum(x), mrb_fixnum(y), &div, &mod);
return mrb_assoc_new(mrb, mrb_fixnum_value(div), mrb_fixnum_value(mod));
@@ -867,8 +867,8 @@ fix_divmod(mrb_state *mrb, mrb_value x)
mrb_value a, b;
flodivmod(mrb, (mrb_float)mrb_fixnum(x), mrb_to_flo(mrb, y), &div, &mod);
- a = mrb_float_value((mrb_int)div);
- b = mrb_float_value(mod);
+ a = mrb_float_value(mrb, (mrb_int)div);
+ b = mrb_float_value(mrb, mod);
return mrb_assoc_new(mrb, a, b);
}
}
@@ -1121,7 +1121,7 @@ fix_to_f(mrb_state *mrb, mrb_value num)
val = (mrb_float)mrb_fixnum(num);
- return mrb_float_value(val);
+ return mrb_float_value(mrb, val);
}
/*
@@ -1175,11 +1175,11 @@ mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y)
c = a + b;
if (((a < 0) ^ (b < 0)) == 0 && (a < 0) != (c < 0)) {
/* integer overflow */
- return mrb_float_value((mrb_float)a + (mrb_float)b);
+ return mrb_float_value(mrb, (mrb_float)a + (mrb_float)b);
}
return mrb_fixnum_value(c);
}
- return mrb_float_value((mrb_float)a + mrb_to_flo(mrb, y));
+ return mrb_float_value(mrb, (mrb_float)a + mrb_to_flo(mrb, y));
}
/* 15.2.8.3.1 */
@@ -1213,11 +1213,11 @@ mrb_fixnum_minus(mrb_state *mrb, mrb_value x, mrb_value y)
c = a - b;
if (((a < 0) ^ (b < 0)) != 0 && (a < 0) != (c < 0)) {
/* integer overflow */
- return mrb_float_value((mrb_float)a - (mrb_float)b);
+ return mrb_float_value(mrb, (mrb_float)a - (mrb_float)b);
}
return mrb_fixnum_value(c);
}
- return mrb_float_value((mrb_float)a - mrb_to_flo(mrb, y));
+ return mrb_float_value(mrb, (mrb_float)a - mrb_to_flo(mrb, y));
}
/* 15.2.8.3.2 */
@@ -1347,7 +1347,7 @@ flo_plus(mrb_state *mrb, mrb_value self)
x = mrb_float(self);
mrb_get_args(mrb, "f", &y);
- return mrb_float_value(x + y);
+ return mrb_float_value(mrb, x + y);
}
/* ------------------------------------------------------------------------*/
void
diff --git a/src/object.c b/src/object.c
index 09dfba41e..a2162f77f 100644
--- a/src/object.c
+++ b/src/object.c
@@ -571,13 +571,13 @@ mrb_Float(mrb_state *mrb, mrb_value val)
}
switch (mrb_type(val)) {
case MRB_TT_FIXNUM:
- return mrb_float_value((mrb_float)mrb_fixnum(val));
+ return mrb_float_value(mrb, (mrb_float)mrb_fixnum(val));
case MRB_TT_FLOAT:
return val;
case MRB_TT_STRING:
- return mrb_float_value(mrb_str_to_dbl(mrb, val, TRUE));
+ return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE));
default:
return mrb_convert_type(mrb, val, MRB_TT_FLOAT, "Float", "to_f");
diff --git a/src/string.c b/src/string.c
index 9bc178499..77f81ecc6 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2222,7 +2222,7 @@ mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck)
static mrb_value
mrb_str_to_f(mrb_state *mrb, mrb_value self)
{
- return mrb_float_value(mrb_str_to_dbl(mrb, self, 0/*Qfalse*/));
+ return mrb_float_value(mrb, mrb_str_to_dbl(mrb, self, 0/*Qfalse*/));
}
/* 15.2.10.5.40 */
diff --git a/src/vm.c b/src/vm.c
index 9d615e50f..38e3cd6ed 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -39,9 +39,11 @@ void abort(void);
#define SET_SYM_VALUE(r,v) MRB_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
#define SET_OBJ_VALUE(r,v) MRB_SET_VALUE(r, (((struct RObject*)(v))->tt), value.p, (v))
#ifdef MRB_NAN_BOXING
-#define SET_FLT_VALUE(r,v) r.f = (v)
+#define SET_FLT_VALUE(mrb,r,v) r.f = (v)
+#elif defined(MRB_WORD_BOXING)
+#define SET_FLT_VALUE(mrb,r,v) r = mrb_float_value(mrb, (v))
#else
-#define SET_FLT_VALUE(r,v) MRB_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
+#define SET_FLT_VALUE(mrb,r,v) MRB_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
#endif
#define STACK_INIT_SIZE 128
@@ -1243,7 +1245,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
L_RAISE:
ci = mrb->c->ci;
- mrb_obj_iv_ifnone(mrb, mrb->exc, mrb_intern2(mrb, "lastpc", 6), mrb_voidp_value(pc));
+ mrb_obj_iv_ifnone(mrb, mrb->exc, mrb_intern2(mrb, "lastpc", 6), mrb_voidp_value(mrb, pc));
mrb_obj_iv_ifnone(mrb, mrb->exc, mrb_intern2(mrb, "ciidx", 5), mrb_fixnum_value(ci - mrb->c->cibase));
eidx = ci->eidx;
if (ci == mrb->c->cibase) {
@@ -1441,6 +1443,8 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
#define attr_i value.i
#ifdef MRB_NAN_BOXING
#define attr_f f
+#elif defined(MRB_WORD_BOXING)
+#define attr_f value.fp->f
#else
#define attr_f value.f
#endif
@@ -1464,27 +1468,45 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
x = mrb_fixnum(regs_a[0]);
y = mrb_fixnum(regs_a[1]);
z = x + y;
+#ifdef MRB_WORD_BOXING
+ z = (z << MRB_FIXNUM_SHIFT) / (1 << MRB_FIXNUM_SHIFT);
+#endif
if ((x < 0) != (z < 0) && ((x < 0) ^ (y < 0)) == 0) {
/* integer overflow */
- SET_FLT_VALUE(regs_a[0], (mrb_float)x + (mrb_float)y);
- }
- else {
- regs_a[0].attr_i = z;
+ SET_FLT_VALUE(mrb, regs_a[0], (mrb_float)x + (mrb_float)y);
+ break;
}
+ SET_INT_VALUE(regs[a], z);
}
break;
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FLOAT):
{
mrb_int x = mrb_fixnum(regs[a]);
mrb_float y = mrb_float(regs[a+1]);
- SET_FLT_VALUE(regs[a], (mrb_float)x + y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x + y);
}
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FIXNUM):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_int y = mrb_fixnum(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x + y);
+ }
+#else
OP_MATH_BODY(+,attr_f,attr_i);
+#endif
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_float y = mrb_float(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x + y);
+ }
+#else
OP_MATH_BODY(+,attr_f,attr_f);
+#endif
break;
case TYPES2(MRB_TT_STRING,MRB_TT_STRING):
regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]);
@@ -1509,9 +1531,12 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
x = mrb_fixnum(regs[a]);
y = mrb_fixnum(regs[a+1]);
z = x - y;
+#ifdef MRB_WORD_BOXING
+ z = (z << MRB_FIXNUM_SHIFT) / (1 << MRB_FIXNUM_SHIFT);
+#endif
if (((x < 0) ^ (y < 0)) != 0 && (x < 0) != (z < 0)) {
/* integer overflow */
- SET_FLT_VALUE(regs[a], (mrb_float)x - (mrb_float)y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x - (mrb_float)y);
break;
}
SET_INT_VALUE(regs[a], z);
@@ -1521,14 +1546,30 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
{
mrb_int x = mrb_fixnum(regs[a]);
mrb_float y = mrb_float(regs[a+1]);
- SET_FLT_VALUE(regs[a], (mrb_float)x - y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x - y);
}
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FIXNUM):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_int y = mrb_fixnum(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x - y);
+ }
+#else
OP_MATH_BODY(-,attr_f,attr_i);
+#endif
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_float y = mrb_float(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x - y);
+ }
+#else
OP_MATH_BODY(-,attr_f,attr_f);
+#endif
break;
default:
goto L_SEND;
@@ -1549,8 +1590,11 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
x = mrb_fixnum(regs[a]);
y = mrb_fixnum(regs[a+1]);
z = x * y;
+#ifdef MRB_WORD_BOXING
+ z = (z << MRB_FIXNUM_SHIFT) / (1 << MRB_FIXNUM_SHIFT);
+#endif
if (x != 0 && z/x != y) {
- SET_FLT_VALUE(regs[a], (mrb_float)x * (mrb_float)y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x * (mrb_float)y);
}
else {
SET_INT_VALUE(regs[a], z);
@@ -1561,14 +1605,30 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
{
mrb_int x = mrb_fixnum(regs[a]);
mrb_float y = mrb_float(regs[a+1]);
- SET_FLT_VALUE(regs[a], (mrb_float)x * y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x * y);
}
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FIXNUM):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_int y = mrb_fixnum(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x * y);
+ }
+#else
OP_MATH_BODY(*,attr_f,attr_i);
+#endif
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_float y = mrb_float(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x * y);
+ }
+#else
OP_MATH_BODY(*,attr_f,attr_f);
+#endif
break;
default:
goto L_SEND;
@@ -1586,21 +1646,37 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
{
mrb_int x = mrb_fixnum(regs[a]);
mrb_int y = mrb_fixnum(regs[a+1]);
- SET_FLT_VALUE(regs[a], (mrb_float)x / (mrb_float)y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x / (mrb_float)y);
}
break;
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FLOAT):
{
mrb_int x = mrb_fixnum(regs[a]);
mrb_float y = mrb_float(regs[a+1]);
- SET_FLT_VALUE(regs[a], (mrb_float)x / y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x / y);
}
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FIXNUM):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_int y = mrb_fixnum(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x / y);
+ }
+#else
OP_MATH_BODY(/,attr_f,attr_i);
+#endif
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ mrb_float y = mrb_float(regs[a+1]);
+ SET_FLT_VALUE(mrb, regs[a], x / y);
+ }
+#else
OP_MATH_BODY(/,attr_f,attr_f);
+#endif
break;
default:
goto L_SEND;
@@ -1622,14 +1698,21 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
if (((x < 0) ^ (y < 0)) == 0 && (x < 0) != (z < 0)) {
/* integer overflow */
- SET_FLT_VALUE(regs[a], (mrb_float)x + (mrb_float)y);
+ SET_FLT_VALUE(mrb, regs[a], (mrb_float)x + (mrb_float)y);
break;
}
regs[a].attr_i = z;
}
break;
case MRB_TT_FLOAT:
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ SET_FLT_VALUE(mrb, regs[a], x + GETARG_C(i));
+ }
+#else
regs[a].attr_f += GETARG_C(i);
+#endif
break;
default:
SET_INT_VALUE(regs[a+1], GETARG_C(i));
@@ -1654,7 +1737,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
if ((x < 0) != (z < 0) && ((x < 0) ^ (y < 0)) != 0) {
/* integer overflow */
- SET_FLT_VALUE(regs_a[0], (mrb_float)x - (mrb_float)y);
+ SET_FLT_VALUE(mrb, regs_a[0], (mrb_float)x - (mrb_float)y);
}
else {
regs_a[0].attr_i = z;
@@ -1662,7 +1745,14 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
}
break;
case MRB_TT_FLOAT:
+#ifdef MRB_WORD_BOXING
+ {
+ mrb_float x = mrb_float(regs[a]);
+ SET_FLT_VALUE(mrb, regs[a], x - GETARG_C(i));
+ }
+#else
regs_a[0].attr_f -= GETARG_C(i);
+#endif
break;
default:
SET_INT_VALUE(regs_a[1], GETARG_C(i));