Will Coleda wrote:
Now that we can subclass PMCs with Objects, we need to go through all the code in src/pmc/*.pmc that directly fiddles with PMC guts (e.g. PMC_int_val(...) and PMC_num_val(...) and replace them with VTABLE accessor methods, or constructs like SELF.get_integer().
Just for clarification, it attached patch is actually what this ticket about?
-- Bacek
diff --git a/src/pmc/bigint.pmc b/src/pmc/bigint.pmc index 9399eae..0c00f18 100644 --- a/src/pmc/bigint.pmc +++ b/src/pmc/bigint.pmc @@ -746,7 +746,7 @@ MMD_Integer: { else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_add_bigint_int(INTERP, SELF, PMC_int_val(value), dest); + bigint_add_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } MMD_DEFAULT: { @@ -804,7 +804,7 @@ MMD_Integer: { else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_sub_bigint_int(INTERP, SELF, PMC_int_val(value), dest); + bigint_sub_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } MMD_DEFAULT: { @@ -862,7 +862,7 @@ MMD_Integer: { else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_mul_bigint_int(INTERP, SELF, PMC_int_val(value), dest); + bigint_mul_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } MMD_DEFAULT: { @@ -886,7 +886,7 @@ MMD_BigInt: { bigint_mul_bigint(INTERP, SELF, value, SELF); } MMD_Integer: { - bigint_mul_bigint_int(INTERP, SELF, PMC_int_val(value), SELF); + bigint_mul_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF); } MMD_DEFAULT: { Parrot_ex_throw_from_c_args(INTERP, NULL, @@ -943,7 +943,7 @@ MMD_Integer: { else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_div_bigint_int(INTERP, SELF, PMC_int_val(value), dest); + bigint_div_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } MMD_DEFAULT: { @@ -967,7 +967,7 @@ MMD_BigInt: { bigint_div_bigint(INTERP, SELF, value, SELF); } MMD_Integer: { - bigint_div_bigint_int(INTERP, SELF, PMC_int_val(value), SELF); + bigint_div_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF); } MMD_DEFAULT: { Parrot_ex_throw_from_c_args(INTERP, NULL, @@ -994,7 +994,7 @@ MMD_Integer: { VTABLE_morph(interp, dest, SELF->vtable->base_type); else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_fdiv_bigint_int(INTERP, SELF, PMC_int_val(value), dest); + bigint_fdiv_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } MMD_DEFAULT: { @@ -1018,7 +1018,7 @@ MMD_BigInt: { bigint_fdiv_bigint(INTERP, SELF, value, SELF); } MMD_Integer: { - bigint_fdiv_bigint_int(INTERP, SELF, PMC_int_val(value), SELF); + bigint_fdiv_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF); } MMD_DEFAULT: { Parrot_ex_throw_from_c_args(INTERP, NULL, @@ -1046,7 +1046,7 @@ MMD_Integer: { else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_mod_bigint_int(INTERP, SELF, PMC_int_val(value), dest); + bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } MMD_DEFAULT: { @@ -1072,7 +1072,7 @@ MMD_BigInt: { bigint_mod_bigint(INTERP, SELF, value, SELF); } MMD_Integer: { - bigint_mod_bigint_int(INTERP, SELF, PMC_int_val(value), SELF); + bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF); } MMD_DEFAULT: { Parrot_ex_throw_from_c_args(INTERP, NULL, @@ -1085,7 +1085,7 @@ MMD_BigInt: { bigint_mod_bigint(INTERP, SELF, value, SELF); } MMD_Integer: { - bigint_mod_bigint_int(INTERP, SELF, PMC_int_val(value), SELF); + bigint_mod_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF); } MMD_DEFAULT: { Parrot_ex_throw_from_c_args(INTERP, NULL, @@ -1099,7 +1099,7 @@ MMD_BigInt: { return bigint_cmp(INTERP, SELF, value); } MMD_Integer: { - return bigint_cmp_int(INTERP, SELF, PMC_int_val(value)); + return bigint_cmp_int(INTERP, SELF, VTABLE_get_integer(interp, value)); } MMD_DEFAULT: { Parrot_ex_throw_from_c_args(INTERP, NULL, @@ -1112,7 +1112,7 @@ MMD_BigInt: { return bigint_cmp(INTERP, SELF, value) == 0; } MMD_Integer: { - return bigint_cmp_int(INTERP, SELF, PMC_int_val(value)) == 0; + return bigint_cmp_int(INTERP, SELF, VTABLE_get_integer(interp, value)) == 0; } MMD_DEFAULT: { Parrot_ex_throw_from_c_args(INTERP, NULL, @@ -1205,7 +1205,7 @@ MMD_Integer: { else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_bitwise_shl_bigint_int(INTERP, SELF, PMC_int_val(value), + bigint_bitwise_shl_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } @@ -1233,7 +1233,7 @@ MMD_BigInt: { SELF); } MMD_Integer: { - bigint_bitwise_shl_bigint_int(INTERP, SELF, PMC_int_val(value), + bigint_bitwise_shl_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF); } MMD_DEFAULT: { @@ -1282,7 +1282,7 @@ MMD_Integer: { else dest = pmc_new(INTERP, SELF->vtable->base_type); - bigint_bitwise_shr_bigint_int(INTERP, SELF, PMC_int_val(value), + bigint_bitwise_shr_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), dest); return dest; } @@ -1310,7 +1310,7 @@ MMD_BigInt: { SELF); } MMD_Integer: { - bigint_bitwise_shr_bigint_int(INTERP, SELF, PMC_int_val(value), + bigint_bitwise_shr_bigint_int(INTERP, SELF, VTABLE_get_integer(interp, value), SELF); } MMD_DEFAULT: {