[svn:parrot] r39325 - in trunk: include/parrot src src/pmc t/op
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue Jun 2 09:32:42 UTC 2009
Author: bacek
Date: Tue Jun 2 09:32:41 2009
New Revision: 39325
URL: https://trac.parrot.org/parrot/changeset/39325
Log:
Revert last 6 commits. They doesn't belong to trunk. bacek--
Modified:
trunk/include/parrot/pmc.h
trunk/src/pmc.c
trunk/src/pmc/bigint.pmc
trunk/src/pmc/bignum.pmc
trunk/src/pmc/integer.pmc
trunk/t/op/arithmetics.t
Modified: trunk/include/parrot/pmc.h
==============================================================================
--- trunk/include/parrot/pmc.h Tue Jun 2 09:19:58 2009 (r39324)
+++ trunk/include/parrot/pmc.h Tue Jun 2 09:32:41 2009 (r39325)
@@ -49,6 +49,16 @@
__attribute__nonnull__(1);
PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
+PMC* Parrot_pmc_try_reuse(PARROT_INTERP,
+ ARGIN(PMC *self),
+ ARGIN_NULLOK(PMC * value),
+ ARGIN_NULLOK(PMC *dest))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
INTVAL PMC_is_null(SHIM_INTERP, ARGIN_NULLOK(const PMC *pmc));
PARROT_EXPORT
@@ -133,6 +143,9 @@
|| PARROT_ASSERT_ARG(pmc)
#define ASSERT_ARGS_Parrot_create_mro __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_pmc_try_reuse __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(self)
#define ASSERT_ARGS_PMC_is_null __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_pmc_new __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c Tue Jun 2 09:19:58 2009 (r39324)
+++ trunk/src/pmc.c Tue Jun 2 09:32:41 2009 (r39325)
@@ -227,6 +227,56 @@
/*
+=item C<PMC* Parrot_pmc_try_reuse(PARROT_INTERP, PMC *self, PMC * value, PMC
+*dest)>
+
+Try to reuse dest PMC if possible. We are going to kill C<dest> anyway. So try
+to reuse it before.
+
+TODO Write nice POD about sideeffects here.
+
+=cut
+*/
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
+PMC*
+Parrot_pmc_try_reuse(PARROT_INTERP, ARGIN(PMC *self), ARGIN_NULLOK(PMC * value),
+ ARGIN_NULLOK(PMC *dest))
+{
+ ASSERT_ARGS(Parrot_pmc_try_reuse)
+ /* Can't reuse dest because we'll lost value */
+ if (dest == value)
+ return pmc_new(interp, VTABLE_type(interp, self));
+
+ /* Can't reuse Null */
+ if (PMC_IS_NULL(dest))
+ return pmc_new(interp, VTABLE_type(interp, self));
+
+ /* Can't reuse read-only variables */
+ if (dest->vtable->flags & VTABLE_IS_READONLY_FLAG)
+ return pmc_new(interp, VTABLE_type(interp, self));
+
+ /* It's safe in this case. Caller want to replace us anyway */
+ if (dest == self)
+ return dest;
+
+ /* Morph to self type is required */
+ {
+ INTVAL type = VTABLE_type(interp, self);
+ if (type >= enum_class_core_max)
+ /* We are not core PMC. Just clone self to preserve semantic of VTABLEs */
+ dest = VTABLE_clone(interp, self);
+ else
+ pmc_reuse(interp, dest, type, 0);
+ }
+
+ return dest;
+}
+
+
+/*
=item C<static void check_pmc_reuse_flags(PARROT_INTERP, UINTVAL srcflags,
UINTVAL destflags)>
Modified: trunk/src/pmc/bigint.pmc
==============================================================================
--- trunk/src/pmc/bigint.pmc Tue Jun 2 09:19:58 2009 (r39324)
+++ trunk/src/pmc/bigint.pmc Tue Jun 2 09:32:41 2009 (r39325)
@@ -837,14 +837,14 @@
}
MULTI PMC *add(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_add_bigint(INTERP, SELF, value, dest);
return dest;
}
MULTI PMC *add(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_add_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -859,7 +859,7 @@
}
VTABLE PMC *add_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_add_bigint_int(INTERP, SELF, value, dest);
return dest;
@@ -893,14 +893,14 @@
MULTI PMC *subtract(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_sub_bigint(INTERP, SELF, value, dest);
return dest;
}
MULTI PMC *subtract(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_sub_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -915,7 +915,7 @@
}
VTABLE PMC *subtract_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_sub_bigint_int(INTERP, SELF, value, dest);
return dest;
@@ -949,14 +949,14 @@
MULTI PMC *multiply(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_mul_bigint(INTERP, SELF, value, dest);
return dest;
}
MULTI PMC *multiply(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_mul_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -971,7 +971,7 @@
}
VTABLE PMC *multiply_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_mul_bigint_int(INTERP, SELF, value, dest);
return dest;
@@ -1002,7 +1002,7 @@
}
VTABLE PMC *pow_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_pow_bigint_int(INTERP, SELF, value, dest);
return dest;
@@ -1011,7 +1011,7 @@
MULTI PMC *pow(PMC *value, PMC *dest) {
/* XXX only Integer RHS currently */
const INTVAL r = VTABLE_get_integer(INTERP, value);
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_pow_bigint_int(INTERP, SELF, r, dest);
return dest;
@@ -1019,7 +1019,7 @@
MULTI PMC *divide(BigInt value, PMC *dest) {
BIGINT *bi;
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_div_bigint(INTERP, SELF, value, dest);
#if 0
@@ -1035,7 +1035,7 @@
}
MULTI PMC *divide(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_div_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -1050,7 +1050,7 @@
}
VTABLE PMC *divide_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_div_bigint_int(INTERP, SELF, value, dest);
return dest;
@@ -1074,14 +1074,14 @@
}
MULTI PMC *floor_divide(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_fdiv_bigint(INTERP, SELF, value, dest);
return dest;
}
MULTI PMC *floor_divide(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_fdiv_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -1096,7 +1096,7 @@
}
VTABLE PMC *floor_divide_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_fdiv_bigint_int(INTERP, SELF, value, dest);
return dest;
@@ -1122,14 +1122,14 @@
}
MULTI PMC *modulus(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_mod_bigint(INTERP, SELF, value, dest);
return dest;
}
MULTI PMC *modulus(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -1199,7 +1199,7 @@
*/
VTABLE PMC *absolute(PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_abs(INTERP, SELF, dest);
return dest;
@@ -1223,7 +1223,7 @@
*/
VTABLE PMC *neg(PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_neg(INTERP, SELF, dest);
return dest;
@@ -1252,7 +1252,7 @@
*/
MULTI PMC *bitwise_shl(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_bitwise_shl_bigint_int(INTERP, SELF,
VTABLE_get_integer(INTERP, value),
@@ -1261,7 +1261,7 @@
}
MULTI PMC *bitwise_shl(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_bitwise_shl_bigint_int(INTERP, SELF,
VTABLE_get_integer(interp, value), dest);
@@ -1276,7 +1276,7 @@
}
VTABLE PMC *bitwise_shl_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_bitwise_shl_bigint_int(INTERP, SELF, value, dest);
return dest;
@@ -1324,7 +1324,7 @@
*/
MULTI PMC *bitwise_shr(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_bitwise_shr_bigint_int(INTERP, SELF,
VTABLE_get_integer(INTERP, value),
@@ -1333,7 +1333,7 @@
}
MULTI PMC *bitwise_shr(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
bigint_bitwise_shr_bigint_int(INTERP, SELF,
VTABLE_get_integer(interp, value), dest);
@@ -1349,7 +1349,7 @@
}
VTABLE PMC *bitwise_shr_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
bigint_bitwise_shr_bigint_int(INTERP, SELF, value, dest);
return dest;
Modified: trunk/src/pmc/bignum.pmc
==============================================================================
--- trunk/src/pmc/bignum.pmc Tue Jun 2 09:19:58 2009 (r39324)
+++ trunk/src/pmc/bignum.pmc Tue Jun 2 09:32:41 2009 (r39325)
@@ -1165,14 +1165,20 @@
*/
MULTI PMC *subtract(BigNum value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_sub_bignum(INTERP, SELF, value, dest);
return dest;
}
MULTI PMC *subtract(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_sub_bignum_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -1186,7 +1192,10 @@
}
VTABLE PMC *subtract_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_sub_bignum_int(INTERP, SELF, value, dest);
return dest;
@@ -1291,7 +1300,10 @@
*/
VTABLE PMC *pow_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_pow_bignum_int(INTERP, SELF, value, dest);
return dest;
@@ -1316,7 +1328,10 @@
MULTI PMC *divide(BigNum value, PMC *dest) {
BIGNUM *bn;
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_div_bignum(INTERP, SELF, value, dest);
#if 0
@@ -1332,7 +1347,10 @@
}
MULTI PMC *divide(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_div_bignum_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -1346,7 +1364,10 @@
}
VTABLE PMC *divide_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_div_bignum_int(INTERP, SELF, value, dest);
return dest;
@@ -1381,14 +1402,14 @@
*/
MULTI PMC *floor_divide(BigNum value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_fdiv_bignum(INTERP, SELF, value, dest);
return dest;
}
MULTI PMC *floor_divide(Integer value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_fdiv_bignum_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
@@ -1402,7 +1423,10 @@
}
VTABLE PMC *floor_divide_int(INTVAL value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ if (dest)
+ pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
bignum_fdiv_bignum_int(INTERP, SELF, value, dest);
return dest;
Modified: trunk/src/pmc/integer.pmc
==============================================================================
--- trunk/src/pmc/integer.pmc Tue Jun 2 09:19:58 2009 (r39324)
+++ trunk/src/pmc/integer.pmc Tue Jun 2 09:32:41 2009 (r39325)
@@ -43,6 +43,7 @@
return self;
}
+
pmclass Integer extends scalar provides integer provides scalar {
ATTR INTVAL iv; /* the value of this Integer */
@@ -347,7 +348,7 @@
const INTVAL c = a + b;
if ((c^a) >= 0 || (c^b) >= 0) {
- dest = pmc_new(INTERP, VTABLE_type(interp, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
/* need this for e.g. Undef PMC */
VTABLE_set_integer_native(INTERP, dest, c);
@@ -384,7 +385,7 @@
MULTI PMC *add(DEFAULT value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(interp, value));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
VTABLE_set_number_native(INTERP, dest,
SELF.get_integer() + VTABLE_get_number(INTERP, value));
@@ -397,7 +398,7 @@
const INTVAL c = a + b;
if ((c^a) >= 0 || (c^b) >= 0) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
VTABLE_set_integer_native(INTERP, dest, c);
return dest;
@@ -486,7 +487,7 @@
const INTVAL c = a - b;
if ((c^a) >= 0 || (c^~b) >= 0) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
VTABLE_set_integer_native(INTERP, dest, c);
return dest;
@@ -522,7 +523,7 @@
MULTI PMC *subtract(DEFAULT value, PMC *dest) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, value));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
VTABLE_set_number_native(INTERP, dest,
SELF.get_integer() - VTABLE_get_number(INTERP, value));
@@ -545,7 +546,7 @@
const INTVAL c = a - b;
if ((c^a) >= 0 || (c^~b) >= 0) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
VTABLE_set_integer_native(INTERP, dest, c);
return dest;
@@ -644,7 +645,7 @@
const double cf = (double)a * (double)b;
if ((double) c == cf) {
- dest = pmc_new(INTERP, VTABLE_type(interp, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
VTABLE_set_integer_native(INTERP, dest, c);
return dest;
@@ -675,7 +676,7 @@
MULTI PMC *multiply(DEFAULT value, PMC *dest) {
const FLOATVAL valf = VTABLE_get_number(INTERP, value);
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
VTABLE_set_number_native(INTERP, dest, SELF.get_number() * valf);
return dest;
@@ -688,7 +689,7 @@
const double cf = (double)a * (double)b;
if ((double) c == cf) {
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
VTABLE_set_integer_native(INTERP, dest, c);
return dest;
@@ -793,7 +794,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
VTABLE_set_number_native(INTERP, dest, SELF.get_number() / d);
return dest;
}
@@ -855,7 +856,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
f = floor(SELF.get_number() / d);
VTABLE_set_integer_native(INTERP, dest, (INTVAL)f);
@@ -870,7 +871,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
f = floor(SELF.get_number() / value);
VTABLE_set_integer_native(INTERP, dest, (INTVAL)f);
@@ -885,7 +886,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
f = floor(SELF.get_number() / value);
VTABLE_set_integer_native(INTERP, dest, (INTVAL)f);
@@ -976,7 +977,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"int modulus by zero");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
VTABLE_set_integer_native(INTERP, dest,
intval_mod(SELF.get_integer(), d));
@@ -989,7 +990,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"int modulus by zero");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
VTABLE_set_integer_native(INTERP, dest,
intval_mod(SELF.get_integer(), value));
@@ -1002,7 +1003,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"int modulus by zero");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
VTABLE_set_integer_native(INTERP, dest,
intval_mod(SELF.get_integer(), (INTVAL)value));
@@ -1121,7 +1122,7 @@
}
}
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
VTABLE_set_integer_native(INTERP, dest, r);
return dest;
@@ -1308,7 +1309,7 @@
const INTVAL a = abs(SELF.get_integer());
/* RT #46635 overflow for -maxint */
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
VTABLE_set_integer_native(INTERP, dest, a);
return dest;
Modified: trunk/t/op/arithmetics.t
==============================================================================
--- trunk/t/op/arithmetics.t Tue Jun 2 09:19:58 2009 (r39324)
+++ trunk/t/op/arithmetics.t Tue Jun 2 09:32:41 2009 (r39325)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 24;
+use Parrot::Test tests => 23;
# test for GMP
use Parrot::Config;
@@ -639,32 +639,6 @@
-Inf
OUTPUT
-# We should generate more tests for all possible combinations
-pir_output_is( <<'CODE', <<OUTPUT, "Original dest is untouched in 3-args arithmetic" );
-.sub 'test' :main
- $P0 = new 'Integer'
- $P0 = 40
- $P1 = new 'Integer'
- $P1 = 2
- $P2 = new 'Integer'
-
- $P99 = $P2
- $P2 = add $P0, $P1
- say $P2
- say $P99
-
- $P99 = $P2
- $P2 = concat $P0, $P1
- say $P2
- say $P99
-.end
-CODE
-42
-0
-402
-42
-OUTPUT
-
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
More information about the parrot-commits
mailing list