[svn:parrot] r38947 - branches/tt452_reduce_mmd/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue May 19 22:52:03 UTC 2009


Author: bacek
Date: Tue May 19 22:52:03 2009
New Revision: 38947
URL: https://trac.parrot.org/parrot/changeset/38947

Log:
[pmc] Fix Integer.modulus for BigInt argument

Modified:
   branches/tt452_reduce_mmd/src/pmc/integer.pmc

Modified: branches/tt452_reduce_mmd/src/pmc/integer.pmc
==============================================================================
--- branches/tt452_reduce_mmd/src/pmc/integer.pmc	Tue May 19 22:32:20 2009	(r38946)
+++ branches/tt452_reduce_mmd/src/pmc/integer.pmc	Tue May 19 22:52:03 2009	(r38947)
@@ -967,23 +967,26 @@
 
 
     VTABLE PMC *modulus(PMC *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");
-
         switch (value->vtable->base_type) {
             case enum_class_BigInt:
-                maybe_throw_overflow_error(INTERP);
-                return VTABLE_modulus(INTERP, VTABLE_get_bignum(INTERP, SELF), value, dest);
+                {
+                    PMC *temp = VTABLE_get_bignum(INTERP, SELF);
+                    maybe_throw_overflow_error(INTERP);
+                    return VTABLE_modulus(INTERP, temp, value, dest);
+                }
                 break;
 
             default:
-                dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+                {
+                    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");
 
-                VTABLE_set_integer_native(INTERP, dest,
+                    dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+                    VTABLE_set_integer_native(INTERP, dest,
                         intval_mod(SELF.get_integer(), d));
+                }
                 return dest;
         }
     }


More information about the parrot-commits mailing list