Skip to content

Commit

Permalink
[pmc] Integer.multiply use i_multiply now.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/branches/pmc_i_ops@39360 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bacek committed Jun 3, 2009
1 parent 8ff7029 commit d032822
Showing 1 changed file with 6 additions and 57 deletions.
63 changes: 6 additions & 57 deletions src/pmc/integer.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -523,68 +523,17 @@ Multiplies the integer by C<*value> and returns the result in C<*dest>.

*/

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;
}

/*
Expand Down

0 comments on commit d032822

Please sign in to comment.