[svn:parrot] r39363 - branches/pmc_i_ops/src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Wed Jun 3 13:34:55 UTC 2009
Author: bacek
Date: Wed Jun 3 13:34:54 2009
New Revision: 39363
URL: https://trac.parrot.org/parrot/changeset/39363
Log:
[pmc] Integer.modulus use i_modulus.
Modified:
branches/pmc_i_ops/src/pmc/integer.pmc
Modified: branches/pmc_i_ops/src/pmc/integer.pmc
==============================================================================
--- branches/pmc_i_ops/src/pmc/integer.pmc Wed Jun 3 13:34:34 2009 (r39362)
+++ branches/pmc_i_ops/src/pmc/integer.pmc Wed Jun 3 13:34:54 2009 (r39363)
@@ -745,51 +745,23 @@
*/
- MULTI PMC *modulus(BigInt value, PMC *dest) {
- PMC *temp;
- maybe_throw_overflow_error(INTERP);
- temp = VTABLE_get_bignum(INTERP, SELF);
- return VTABLE_modulus(INTERP, temp, value, dest);
- }
-
-
- MULTI PMC *modulus(DEFAULT value, PMC *dest) {
- const INTVAL d = VTABLE_get_integer(INTERP, value);
-
- if (d == 0)
- Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
- "int modulus by zero");
-
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-
- VTABLE_set_integer_native(INTERP, dest,
- intval_mod(SELF.get_integer(), d));
+ MULTI PMC *modulus(PMC *value, PMC *dest) {
+ dest = VTABLE_clone(INTERP, SELF);
+ VTABLE_i_modulus(INTERP, dest, value);
return dest;
}
VTABLE PMC *modulus_int(INTVAL value, PMC *dest) {
- if (value == 0)
- Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
- "int modulus by zero");
-
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-
- VTABLE_set_integer_native(INTERP, dest,
- intval_mod(SELF.get_integer(), value));
+ dest = VTABLE_clone(INTERP, SELF);
+ STATICSELF.i_modulus_int(value);
return dest;
}
VTABLE PMC *modulus_float(FLOATVAL value, PMC *dest) {
- if (FLOAT_IS_ZERO(value))
- Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_DIV_BY_ZERO,
- "int modulus by zero");
-
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-
- VTABLE_set_integer_native(INTERP, dest,
- intval_mod(SELF.get_integer(), (INTVAL)value));
+ dest = VTABLE_clone(INTERP, SELF);
+ STATICSELF.i_modulus_float(value);
return dest;
}
@@ -818,7 +790,7 @@
"int modulus by zero");
VTABLE_set_integer_native(INTERP, SELF,
- intval_mod(SELF.get_integer() , value));
+ intval_mod(SELF.get_integer(), value));
}
@@ -828,7 +800,7 @@
"int modulus by zero");
VTABLE_set_integer_native(INTERP, SELF,
- intval_mod(SELF.get_integer() , (INTVAL)value));
+ intval_mod(SELF.get_integer(), (INTVAL)value));
}
More information about the parrot-commits
mailing list