[svn:parrot] r39309 - trunk/src/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Mon Jun 1 22:47:47 UTC 2009
Author: coke
Date: Mon Jun 1 22:47:46 2009
New Revision: 39309
URL: https://trac.parrot.org/parrot/changeset/39309
Log:
TT #728 - revert r39273 until someone determines the proper implementation.
(This version broke partcl)
Modified:
trunk/src/pmc/scalar.pmc
Modified: trunk/src/pmc/scalar.pmc
==============================================================================
--- trunk/src/pmc/scalar.pmc Mon Jun 1 21:50:54 2009 (r39308)
+++ trunk/src/pmc/scalar.pmc Mon Jun 1 22:47:46 2009 (r39309)
@@ -55,7 +55,12 @@
/* Store the result. */
if (! overflow_p) {
- dest = Parrot_pmc_try_reuse(interp, self, NULL, dest);
+ /* If SELF is the destination, we won't want to create a
+ new PMC, because then we won't have the result in SELF.
+ Only create a new PMC if we aren't saving the result
+ to SELF, or if they are both NULL */
+ if (dest != self || dest == NULL)
+ dest = pmc_new(interp, VTABLE_type(interp, self));
VTABLE_set_integer_native(interp, dest, result);
}
@@ -169,8 +174,7 @@
MULTI PMC *add(Complex value, PMC *dest) {
const FLOATVAL a = SELF.get_number();
- /* NB: value as second arg */
- dest = Parrot_pmc_try_reuse(interp, value, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, value));
VTABLE_set_number_native(INTERP, dest,
a + VTABLE_get_number_keyed_int(INTERP, value, 0));
@@ -180,7 +184,7 @@
}
MULTI PMC *add(DEFAULT value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() + VTABLE_get_number(INTERP, value));
@@ -188,7 +192,7 @@
}
VTABLE PMC *add_int(INTVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() + (FLOATVAL)value);
@@ -196,7 +200,7 @@
}
VTABLE PMC *add_float(FLOATVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() + value);
@@ -253,7 +257,10 @@
MULTI PMC *subtract(Complex value, PMC *dest) {
const FLOATVAL a = SELF.get_number();
- pmc_reuse(INTERP, SELF, enum_class_Complex, 0);
+ if (dest)
+ pmc_reuse(INTERP, dest, value->vtable->base_type, 0);
+ else
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, value));
VTABLE_set_number_native(INTERP, dest,
a - VTABLE_get_number_keyed_int(INTERP, value, 0));
@@ -263,14 +270,14 @@
}
MULTI PMC *subtract(DEFAULT value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() - VTABLE_get_number(INTERP, value));
return dest;
}
VTABLE PMC *subtract_int(INTVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() - (FLOATVAL)value);
@@ -278,7 +285,7 @@
}
VTABLE PMC *subtract_float(FLOATVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() - value);
@@ -330,7 +337,7 @@
}
MULTI PMC *multiply(DEFAULT value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() * VTABLE_get_number(INTERP, value));
@@ -338,7 +345,7 @@
}
VTABLE PMC *multiply_int(INTVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() * value);
@@ -346,7 +353,7 @@
}
VTABLE PMC *multiply_float(FLOATVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
SELF.get_number() * value);
@@ -402,7 +409,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest, SELF.get_number() / d);
return dest;
@@ -413,7 +420,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest, SELF.get_number() / value);
return dest;
@@ -424,7 +431,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest, SELF.get_number() / value);
return dest;
@@ -485,7 +492,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
d = floor(SELF.get_number() / d);
VTABLE_set_integer_native(INTERP, dest, (INTVAL)d);
@@ -497,7 +504,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
floor(SELF.get_number() / value));
@@ -509,7 +516,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float division by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
floor(SELF.get_number() / value));
@@ -575,7 +582,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float modulus by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
floatval_mod(SELF.get_number(), d));
@@ -587,7 +594,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float modulus by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
floatval_mod(SELF.get_number(), (FLOATVAL)value));
@@ -599,7 +606,7 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
"float modulus by zero");
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
floatval_mod(SELF.get_number(), value));
@@ -661,14 +668,14 @@
MULTI PMC *pow(PMC *value, PMC *dest) {
const FLOATVAL d = VTABLE_get_number(INTERP, value);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest, pow(SELF.get_number(), d));
return dest;
}
VTABLE PMC *pow_int(INTVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
pow(SELF.get_number(), (double)value));
@@ -677,7 +684,7 @@
}
VTABLE PMC *pow_float(FLOATVAL value, PMC *dest) {
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_number_native(INTERP, dest,
pow(SELF.get_number(), value));
@@ -716,7 +723,7 @@
VTABLE PMC *neg(PMC *dest) {
const INTVAL a = -SELF.get_integer();
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, a);
return dest;
@@ -753,7 +760,7 @@
VTABLE PMC *bitwise_or(PMC *value, PMC *dest) {
const INTVAL result = SELF.get_integer() | VTABLE_get_integer(INTERP, value);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -763,7 +770,7 @@
VTABLE PMC *bitwise_or_int(INTVAL value, PMC *dest) {
const INTVAL result = SELF.get_integer() | value;
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -804,7 +811,7 @@
const INTVAL result =
SELF.get_integer() & VTABLE_get_integer(INTERP, value);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -813,7 +820,7 @@
VTABLE PMC *bitwise_and_int(INTVAL value, PMC *dest) {
const INTVAL result = SELF.get_integer() & value;
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -853,7 +860,7 @@
const INTVAL result =
SELF.get_integer() ^ VTABLE_get_integer(INTERP, value);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -862,7 +869,7 @@
VTABLE PMC *bitwise_xor_int(INTVAL value, PMC *dest) {
const INTVAL result = SELF.get_integer() ^ value;
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -894,7 +901,7 @@
VTABLE PMC *bitwise_not(PMC *dest) {
const INTVAL a = ~SELF.get_integer();
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, a);
return dest;
@@ -967,7 +974,7 @@
const INTVAL result = (UINTVAL)SELF.get_integer() >>
VTABLE_get_integer(INTERP, value);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -976,7 +983,7 @@
VTABLE PMC *bitwise_lsr_int(INTVAL value, PMC *dest) {
const INTVAL result = (UINTVAL)SELF.get_integer() >> value;
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_integer_native(INTERP, dest, result);
return dest;
@@ -1059,7 +1066,7 @@
STRING * const s = Parrot_str_concat(INTERP, SELF.get_string(),
VTABLE_get_string(INTERP, value), 0);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_string_native(INTERP, dest, s);
return dest;
@@ -1069,7 +1076,7 @@
STRING * const s = Parrot_str_concat(INTERP,
SELF.get_string(), value, 0);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_string_native(INTERP, dest, s);
return dest;
@@ -1108,7 +1115,7 @@
STRING * const s = SELF.get_string();
const UINTVAL n = (UINTVAL)VTABLE_get_integer(INTERP, value);
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_string_native(INTERP, dest,
Parrot_str_repeat(INTERP, s, n));
@@ -1119,7 +1126,7 @@
STRING * const s = SELF.get_string();
const UINTVAL n = value;
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_string_native(INTERP, dest,
Parrot_str_repeat(INTERP, s, n));
@@ -1291,7 +1298,7 @@
else if (value_bool && ! my_bool)
return value;
- dest = Parrot_pmc_try_reuse(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_bool(INTERP, dest, 0);
return dest;
}
@@ -1312,7 +1319,7 @@
VTABLE PMC *logical_not(PMC *dest) {
const INTVAL a = ! SELF.get_bool();
- dest = Parrot_pmc_try_reuse(INTERP, SELF, NULL, dest);
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
VTABLE_set_bool(INTERP, dest, a);
return dest;
More information about the parrot-commits
mailing list