# New Ticket Created by Paul Cochrane # Please include the string: [perl #50938] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=50938 >
Hi all, the attached patch removes the instantiate opcode (see RT#48022). The patch also removes three tests in t/pmc/integer.t, which is something I'm not 100% sure about. After I'd tried to update the tests to use "new" instead of "instantiate" (but without total success), and after an off-list discussion with kjs++, I got the feeling that the three tests were basically testing the "instantiate" opcode and so since the opcode is no longer there, that the tests should be removed. However, since I'm somewhat loath to remove tests it was decided it would be best to ask the list. So, yeah, what are people's opinions? TIA Paul
Index: src/ops/experimental.ops =================================================================== --- src/ops/experimental.ops (revision 25791) +++ src/ops/experimental.ops (working copy) @@ -319,7 +319,7 @@ =item B<new>(out PMC, in INT, in STR) Create a new PMC of the type $2 according to the PMCs string representation -in $3. See also B<instantiate> for a more general form. +in $3. BUT SINCE INSTANTIATE WILL PROBABLY DIE, DON'T USE THIS; OR IF YOU NEED THIS (OR INSTANTIATE), TELL CHIP @@ -337,54 +337,6 @@ goto NEXT(); } -=item B<instantiate>(out PMC) - -Create a new PMC of the type of class ARGS[0]. This is a classmethod. -Arguments are passed according to the calling conventions in -F<docs/pdds/pdd03_calling_conventions.pod> with the C<set_args> opcode. -See also the I<get_class> opcode to get a class PMC. -BUT SINCE INSTANTIATE WILL PROBABLY DIE, DON'T USE IT; -OR IF YOU NEED IT, TELL CHIP - -=cut - -op instantiate(out PMC) { - opcode_t* arg_op; - PMC *sig, *_class; - int typ; - - arg_op = interp->current_args; - if (!arg_op) { - real_exception(interp, NULL, NULL_REG_ACCESS, - "No set_args with instantiate"); - } - sig = CONTEXT(interp->ctx)->constants[arg_op[1]]->u.key; - ASSERT_SIG_PMC(sig); - if (!SIG_ELEMS(sig)) { - real_exception(interp, NULL, E_ValueError, - "Empty signature with instantiate"); - } - switch (SIG_ITEM(sig, 0)) { - case PARROT_ARG_IC: - typ = arg_op[2]; - if (typ <= 1 || typ >= interp->n_vtable_max) { - real_exception(interp, NULL, E_ValueError, - "Illegal PMC enum (%d) in instantiate", typ); - } - _class = interp->vtables[typ]->pmc_class; - break; - case PARROT_ARG_P: - _class = REG_PMC(interp, arg_op[2]); - break; - default: - real_exception(interp, NULL, UNIMPLEMENTED, - "unimplemented class argument in instantiate"); - } - $1 = VTABLE_instantiate(interp, _class, sig); - interp->current_args = NULL; - goto NEXT(); -} - ######################################## =item B<add_io_event>(invar PMC, invar PMC, invar PMC, inconst INT) Index: DEPRECATED.pod =================================================================== --- DEPRECATED.pod (revision 25791) +++ DEPRECATED.pod (working copy) @@ -112,10 +112,6 @@ See RT #47011. -=item * C<instantiate> [post 0.5.0] - -See RT #48022. - =item * C<getclass> [post 0.5.0] See RT #47972. Future use should use the C<get_class> opcode. Index: t/pmc/integer.t =================================================================== --- t/pmc/integer.t (revision 25791) +++ t/pmc/integer.t (working copy) @@ -469,59 +469,6 @@ 1b OUTPUT -pir_output_is( << 'CODE', << 'OUTPUT', "instantiate" ); - -.sub _main - .local pmc cl, o - cl = getclass "Integer" - set_args '(0)', cl - o = instantiate - print o - print "\n" - $S0 = typeof o - print $S0 - print "\n" -.end -CODE -0 -Integer -OUTPUT - -pir_output_is( <<'CODE', <<'OUTPUT', 'instantiate derived' ); -.sub _main :main - .local pmc cl, o - cl = getclass "Integer" - set_args '(0)', cl - o = instantiate - print o - print "\n" - $S0 = typeof o - print $S0 - print "\n" -.end -CODE -0 -Integer -OUTPUT - -pir_output_is( << 'CODE', << 'OUTPUT', "instantiate w arg" ); - -.sub _main - .local pmc cl, o - cl = getclass "Integer" - set_args '(0,0)', cl, 42 - o = instantiate - print o - print "\n" - $S0 = typeof o - print $S0 - print "\n" -.end -CODE -42 -Integer -OUTPUT - # Local Variables: # mode: cperl # cperl-indent-level: 4