[svn:parrot] r39360 - branches/pmc_i_ops/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Jun 3 13:33:55 UTC 2009


Author: bacek
Date: Wed Jun  3 13:33:55 2009
New Revision: 39360
URL: https://trac.parrot.org/parrot/changeset/39360

Log:
[pmc] Integer.multiply use i_multiply now.

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:33:33 2009	(r39359)
+++ branches/pmc_i_ops/src/pmc/integer.pmc	Wed Jun  3 13:33:55 2009	(r39360)
@@ -523,68 +523,17 @@
 
 */
 
-    MULTI PMC *multiply(Integer value, PMC *dest) {
-        const INTVAL a  = VTABLE_get_integer(INTERP, SELF);
-        const INTVAL b  = VTABLE_get_integer(INTERP, value);
-        const INTVAL c  = a * b;
-        const double cf = (double)a * (double)b;
-
-        if ((double) c == cf) {
-            dest = pmc_new(INTERP, VTABLE_type(interp, SELF));
-
-            VTABLE_set_integer_native(INTERP, dest, c);
-            return dest;
-        }
-        else {
-            PMC *temp;
-            maybe_throw_overflow_error(INTERP);
-            temp = VTABLE_get_bignum(INTERP, SELF);
-            return VTABLE_multiply(INTERP, temp, value, dest);
-        }
-    }
-
-
-    MULTI PMC *multiply(Complex value, PMC *dest) {
-        return VTABLE_multiply(INTERP, value, SELF, dest);
-    }
-
-
-    MULTI PMC *multiply(BigInt value, PMC *dest) {
-        return VTABLE_multiply_int(INTERP, value, SELF.get_integer(), dest);
-    }
-
-
-    MULTI PMC *multiply(String value, PMC *dest) {
-        return Parrot_Integer_multi_multiply_Integer_PMC(INTERP, SELF, value, dest);
-    }
-
-
-    MULTI PMC *multiply(DEFAULT value, PMC *dest) {
-        const FLOATVAL valf = VTABLE_get_number(INTERP, value);
-        dest                = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-
-        VTABLE_set_number_native(INTERP, dest, SELF.get_number() * valf);
+    MULTI PMC *multiply(PMC *value, PMC *dest) {
+        dest = VTABLE_clone(INTERP, SELF);
+        VTABLE_i_multiply(INTERP, dest, value);
         return dest;
     }
 
 
     VTABLE PMC *multiply_int(INTVAL b, PMC *dest) {
-        const INTVAL a  = SELF.get_integer();
-        const INTVAL c  = a * b;
-        const double cf = (double)a * (double)b;
-
-        if ((double) c == cf) {
-            dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-
-            VTABLE_set_integer_native(INTERP, dest, c);
-            return dest;
-        }
-        else {
-            PMC *temp;
-            maybe_throw_overflow_error(INTERP);
-            temp = VTABLE_get_bignum(INTERP, SELF);
-            return VTABLE_multiply_int(INTERP, temp, b, dest);
-        }
+        dest = VTABLE_clone(INTERP, SELF);
+        Integer.dest.i_multiply_int(b);
+        return dest;
     }
 
 /*


More information about the parrot-commits mailing list