[svn:parrot] r38929 - branches/tt452_reduce_mmd/src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue May 19 13:57:18 UTC 2009
Author: bacek
Date: Tue May 19 13:57:17 2009
New Revision: 38929
URL: https://trac.parrot.org/parrot/changeset/38929
Log:
Merge branch 'tt452_mutlis_local' into t452_reduce_mmd_local
Modified:
branches/tt452_reduce_mmd/src/pmc/bigint.pmc
branches/tt452_reduce_mmd/src/pmc/integer.pmc
branches/tt452_reduce_mmd/src/pmc/scalar.pmc
Modified: branches/tt452_reduce_mmd/src/pmc/bigint.pmc
==============================================================================
--- branches/tt452_reduce_mmd/src/pmc/bigint.pmc Tue May 19 13:53:11 2009 (r38928)
+++ branches/tt452_reduce_mmd/src/pmc/bigint.pmc Tue May 19 13:57:17 2009 (r38929)
@@ -836,28 +836,25 @@
bigint_sub_bigint_int(INTERP, SELF, 1, SELF);
}
- MULTI PMC *add(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_add_bigint(INTERP, SELF, value, dest);
- return dest;
- }
-
- MULTI PMC *add(Integer value, PMC *dest) {
+ VTABLE PMC *add(PMC *value, PMC *dest) {
dest = pmc_new(INTERP, SELF->vtable->base_type);
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_add_bigint(INTERP, SELF, value, dest);
+ break;
+ case enum_class_Integer:
+ bigint_add_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'add' for %Ss",
+ VTABLE_name(interp, value));
+ }
- bigint_add_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
return dest;
}
- MULTI PMC *add(DEFAULT value, PMC *dest) {
- UNUSED(dest)
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'add' for %Ss",
- VTABLE_name(interp, value));
- }
-
VTABLE PMC *add_int(INTVAL value, PMC *dest) {
dest = pmc_new(INTERP, SELF->vtable->base_type);
@@ -865,19 +862,21 @@
return dest;
}
- MULTI void i_add(BigInt value) {
- bigint_add_bigint(INTERP, SELF, value, SELF);
- }
-
- MULTI void i_add(Integer value) {
- bigint_add_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
- }
+ VTABLE void i_add(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_add_bigint(INTERP, SELF, value, SELF);
+ break;
+ case enum_class_Integer:
+ bigint_add_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'i_add' for %Ss",
+ VTABLE_name(interp, value));
+ }
- MULTI void i_add(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'i_add' for %Ss",
- VTABLE_name(interp, value));
}
VTABLE void i_add_int(INTVAL value) {
@@ -892,34 +891,24 @@
}
- MULTI PMC *subtract(BigInt value, PMC *dest) {
- if (dest)
- pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
- else
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_sub_bigint(INTERP, SELF, value, dest);
- return dest;
- }
-
- MULTI PMC *subtract(Integer value, PMC *dest) {
- if (dest)
- pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
- else
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_sub_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ VTABLE PMC *subtract(PMC *value, PMC *dest) {
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_sub_bigint(INTERP, SELF, value, dest);
+ break;
+ case enum_class_Integer:
+ bigint_sub_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'subtract' for %Ss",
+ VTABLE_name(interp, value));
+ }
return dest;
}
- MULTI PMC *subtract(DEFAULT value, PMC *dest) {
- UNUSED(dest)
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'subtract' for %Ss",
- VTABLE_name(interp, value));
- }
-
VTABLE PMC *subtract_int(INTVAL value, PMC *dest) {
if (dest)
pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
@@ -930,19 +919,20 @@
return dest;
}
- MULTI void i_subtract(BigInt value) {
- bigint_sub_bigint(INTERP, SELF, value, SELF);
- }
-
- MULTI void i_subtract(Integer value) {
- bigint_sub_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
- }
-
- MULTI void i_subtract(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'i_subtract' for %Ss",
- VTABLE_name(interp, value));
+ VTABLE void i_subtract(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_sub_bigint(INTERP, SELF, value, SELF);
+ break;
+ case enum_class_Integer:
+ bigint_sub_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'i_subtract' for %Ss",
+ VTABLE_name(interp, value));
+ }
}
VTABLE void i_subtract_int(INTVAL value) {
@@ -957,28 +947,24 @@
}
- MULTI PMC *multiply(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_mul_bigint(INTERP, SELF, value, dest);
- return dest;
- }
-
- MULTI PMC *multiply(Integer value, PMC *dest) {
+ VTABLE PMC *multiply(PMC *value, PMC *dest) {
dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_mul_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_mul_bigint(INTERP, SELF, value, dest);
+ break;
+ case enum_class_Integer:
+ bigint_mul_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'multiply' for %Ss",
+ VTABLE_name(interp, value));
+ }
return dest;
}
- MULTI PMC *multiply(DEFAULT value, PMC *dest) {
- UNUSED(dest)
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'multiply' for %Ss",
- VTABLE_name(interp, value));
- }
-
VTABLE PMC *multiply_int(INTVAL value, PMC *dest) {
dest = pmc_new(INTERP, SELF->vtable->base_type);
@@ -986,17 +972,20 @@
return dest;
}
- MULTI void i_multiply(BigInt value) {
- bigint_mul_bigint(INTERP, SELF, value, SELF);
- }
- MULTI void i_multiply(Integer value) {
- bigint_mul_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
- }
- MULTI void i_multiply(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'i_multiply' for %Ss",
- VTABLE_name(interp, value));
+ VTABLE void i_multiply(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_mul_bigint(INTERP, SELF, value, SELF);
+ break;
+ case enum_class_Integer:
+ bigint_mul_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'multiply' for %Ss",
+ VTABLE_name(interp, value));
+ }
}
VTABLE void i_multiply_int(INTVAL value) {
@@ -1029,14 +1018,22 @@
return dest;
}
- MULTI PMC *divide(BigInt value, PMC *dest) {
+ VTABLE PMC *divide(PMC *value, PMC *dest) {
BIGINT *bi;
- if (dest)
- pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
- else
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_div_bigint(INTERP, SELF, value, dest);
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_div_bigint(INTERP, SELF, value, dest);
+ break;
+ case enum_class_Integer:
+ bigint_div_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'divide' for %Ss",
+ VTABLE_name(interp, value));
+ }
#if 0
/* to downgrade or not that's the question */
GETATTR_BigInt_bi(interp, dest, bi);
@@ -1049,24 +1046,6 @@
return dest;
}
- MULTI PMC *divide(Integer value, PMC *dest) {
- if (dest)
- pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
- else
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_div_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
- return dest;
- }
-
- MULTI PMC *divide(DEFAULT value, PMC *dest) {
- UNUSED(dest)
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'divide' for %Ss",
- VTABLE_name(interp, value));
- }
-
VTABLE PMC *divide_int(INTVAL value, PMC *dest) {
if (dest)
pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
@@ -1077,45 +1056,44 @@
return dest;
}
- MULTI void i_divide(BigInt value) {
- bigint_div_bigint(INTERP, SELF, value, SELF);
- }
- MULTI void i_divide(Integer value) {
- bigint_div_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
- }
- MULTI void i_divide(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'i_divide' for %Ss",
- VTABLE_name(interp, value));
+ MULTI void i_divide(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_div_bigint(INTERP, SELF, value, SELF);
+ break;
+ case enum_class_Integer:
+ bigint_div_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'i_divide' for %Ss",
+ VTABLE_name(interp, value));
+ }
}
VTABLE void i_divide_int(INTVAL value) {
bigint_div_bigint_int(INTERP, SELF, value, SELF);
}
- MULTI PMC *floor_divide(BigInt value, PMC *dest) {
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_fdiv_bigint(INTERP, SELF, value, dest);
- return dest;
- }
-
- MULTI PMC *floor_divide(Integer value, PMC *dest) {
+ VTABLE PMC *floor_divide(PMC *value, PMC *dest) {
dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_fdiv_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_fdiv_bigint(INTERP, SELF, value, dest);
+ break;
+ case enum_class_Integer:
+ bigint_fdiv_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'floor_divide' for %Ss",
+ VTABLE_name(interp, value));
+ }
return dest;
}
- MULTI PMC *floor_divide(DEFAULT value, PMC *dest) {
- UNUSED(dest)
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'floor_divide' for %Ss",
- VTABLE_name(interp, value));
- }
-
VTABLE PMC *floor_divide_int(INTVAL value, PMC *dest) {
if (dest)
pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
@@ -1126,94 +1104,86 @@
return dest;
}
- MULTI void i_floor_divide(BigInt value) {
- bigint_fdiv_bigint(INTERP, SELF, value, SELF);
- }
-
- MULTI void i_floor_divide(Integer value) {
- bigint_fdiv_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
- }
-
- MULTI void i_floor_divide(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'i_floor_divide' for %Ss",
- VTABLE_name(interp, value));
+ VTABLE void i_floor_divide(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_fdiv_bigint(INTERP, SELF, value, SELF);
+ break;
+ case enum_class_Integer:
+ bigint_fdiv_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'i_floor_divide' for %Ss",
+ VTABLE_name(interp, value));
+ }
}
VTABLE void i_floor_divide_int(INTVAL value) {
bigint_fdiv_bigint_int(INTERP, SELF, value, SELF);
}
- MULTI PMC *modulus(BigInt value, PMC *dest) {
- if (dest)
- pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
- else
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_mod_bigint(INTERP, SELF, value, dest);
- return dest;
- }
-
- MULTI PMC *modulus(Integer value, PMC *dest) {
- if (dest)
- pmc_reuse(interp, dest, SELF->vtable->base_type, 0);
- else
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ VTABLE PMC *modulus(PMC *value, PMC *dest) {
+ dest = pmc_new(INTERP, SELF->vtable->base_type);
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_mod_bigint(INTERP, SELF, value, dest);
+ break;
+ case enum_class_Integer:
+ bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'modulus' for %Ss",
+ VTABLE_name(interp, value));
+ }
return dest;
}
- MULTI PMC *modulus(DEFAULT value, PMC *dest) {
- UNUSED(dest)
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'modulus' for %Ss",
- VTABLE_name(interp, value));
- }
-
- MULTI void i_modulus(BigInt value) {
- bigint_mod_bigint(INTERP, SELF, value, SELF);
- }
- MULTI void i_modulus(Integer value) {
- bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
- }
- MULTI void i_modulus(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'i_modulus' for %Ss",
- VTABLE_name(interp, value));
- }
-
- MULTI INTVAL cmp(BigInt value) {
- return bigint_cmp(INTERP, SELF, value);
- }
-
- MULTI INTVAL cmp(Integer value) {
- return bigint_cmp_int(INTERP, SELF, VTABLE_get_integer(interp, value));
- }
-
- MULTI INTVAL cmp(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'cmp' for %Ss",
- VTABLE_name(interp, value));
- }
-
- MULTI INTVAL is_equal(BigInt value) {
- return bigint_cmp(INTERP, SELF, value) == 0;
+ VTABLE void i_modulus(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ bigint_mod_bigint(INTERP, SELF, value, SELF);
+ break;
+ case enum_class_Integer:
+ bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'i_modulus' for %Ss",
+ VTABLE_name(interp, value));
+ }
}
- MULTI INTVAL is_equal(Integer value) {
- return bigint_cmp_int(INTERP, SELF, VTABLE_get_integer(interp, value)) == 0;
+ VTABLE INTVAL cmp(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ return bigint_cmp(INTERP, SELF, value);
+ case enum_class_Integer:
+ return bigint_cmp_int(INTERP, SELF, VTABLE_get_integer(interp, value));
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'cmp' for %Ss",
+ VTABLE_name(interp, value));
+ }
}
- MULTI INTVAL is_equal(DEFAULT value) {
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "BigInt: no multiple dispatch variant 'is_equal' for %Ss",
- VTABLE_name(interp, value));
+ VTABLE INTVAL is_equal(PMC *value) {
+ switch (value->vtable->base_type) {
+ case enum_class_BigInt:
+ return bigint_cmp(INTERP, SELF, value) == 0;
+ case enum_class_Integer:
+ return bigint_cmp_int(INTERP, SELF, VTABLE_get_integer(interp, value)) == 0;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ "BigInt: no multiple dispatch variant 'is_equal' for %Ss",
+ VTABLE_name(interp, value));
+ }
}
/*
Modified: branches/tt452_reduce_mmd/src/pmc/integer.pmc
==============================================================================
--- branches/tt452_reduce_mmd/src/pmc/integer.pmc Tue May 19 13:53:11 2009 (r38928)
+++ branches/tt452_reduce_mmd/src/pmc/integer.pmc Tue May 19 13:57:17 2009 (r38929)
@@ -966,26 +966,26 @@
*/
- 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) {
+ 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");
- dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ 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);
+ break;
- VTABLE_set_integer_native(INTERP, dest,
- intval_mod(SELF.get_integer(), d));
- return dest;
+ default:
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+
+ VTABLE_set_integer_native(INTERP, dest,
+ intval_mod(SELF.get_integer(), d));
+ return dest;
+ }
}
@@ -1162,9 +1162,7 @@
case enum_class_BigInt:
temp = pmc_new(INTERP, enum_class_BigInt);
VTABLE_set_integer_native(INTERP, temp, SELF.get_integer());
- Parrot_mmd_multi_dispatch_from_c_args(interp,
- "is_equal", "PP->I", temp, value, &retval);
- return retval;
+ return VTABLE_is_equal(INTERP, temp, value);
break;
default:
return (VTABLE_get_integer(INTERP, SELF)
@@ -1184,31 +1182,35 @@
*/
- MULTI INTVAL cmp(String value) {
- const FLOATVAL fdiff = SELF.get_number() - VTABLE_get_number(INTERP, value);
+ VTABLE INTVAL cmp(PMC *value) {
+ FLOATVAL fdiff;
- if (FLOAT_IS_ZERO(fdiff)) {
- const INTVAL idiff =
- SELF.get_integer() - VTABLE_get_integer(INTERP, value);
- return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
- }
-
- return fdiff > 0 ? 1 : -1;
- }
+ switch (value->vtable->base_type) {
+ case enum_class_String:
+ fdiff = SELF.get_number() - VTABLE_get_number(INTERP, value);
+ if (FLOAT_IS_ZERO(fdiff)) {
+ INTVAL idiff = SELF.get_integer() - VTABLE_get_integer(INTERP, value);
+ return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
+ }
- MULTI INTVAL cmp(Float value) {
- const FLOATVAL diff = SELF.get_number() - VTABLE_get_number(INTERP, value);
- return diff > 0 ? 1 : diff < 0 ? -1 : 0;
- }
+ return fdiff > 0 ? 1 : -1;
+ break;
+ case enum_class_Float:
+ fdiff = SELF.get_number() - VTABLE_get_number(INTERP, value);
+ return fdiff > 0 ? 1 : fdiff < 0 ? -1 : 0;
+ break;
- MULTI INTVAL cmp(DEFAULT value) {
- /* int or undef */
- const INTVAL selfint = SELF.get_integer();
- const INTVAL valueint = VTABLE_get_integer(INTERP, value);
+ default:
+ {
+ /* int or undef */
+ const INTVAL selfint = SELF.get_integer();
+ const INTVAL valueint = VTABLE_get_integer(INTERP, value);
- return selfint > valueint ? 1 : selfint < valueint ? -1 : 0;
+ return selfint > valueint ? 1 : selfint < valueint ? -1 : 0;
+ }
+ }
}
Modified: branches/tt452_reduce_mmd/src/pmc/scalar.pmc
==============================================================================
--- branches/tt452_reduce_mmd/src/pmc/scalar.pmc Tue May 19 13:53:11 2009 (r38928)
+++ branches/tt452_reduce_mmd/src/pmc/scalar.pmc Tue May 19 13:57:17 2009 (r38929)
@@ -1063,8 +1063,8 @@
*/
VTABLE PMC *concatenate(PMC *value, PMC *dest) {
- STRING * const s = Parrot_str_concat(INTERP, SELF.get_string(),
- VTABLE_get_string(INTERP, value), 0);
+ STRING * s = SELF.get_string();
+ s = Parrot_str_append(interp, s, VTABLE_get_string(INTERP, value));
dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
More information about the parrot-commits
mailing list