develooper Front page | perl.perl5.porters | Postings from May 2012

Re: Removing from the opcode tree

Thread Previous
From:
Eric Brine
Date:
May 15, 2012 23:43
Subject:
Re: Removing from the opcode tree
Message ID:
CALJW-qEGmeybwKNoa6=aNSw4jswZLhaTmg26Rpr5My_4zzuysA@mail.gmail.com
On Tue, May 15, 2012 at 7:00 PM, Eric Brine <ikegami@adaelis.com> wrote:

> On Mon, May 14, 2012 at 7:37 PM, Father Chrysostomos via RT <
> perlbug-followup@perl.org> wrote:
> > Replacing the entersub op with something else is what
> > cv_set_call_checker is for.
>
> I haven't found an example that removes from the opcode tree. How would I
> fill in the following call checker
>
> STATIC OP* check_loop(pTHX_ OP* entersubop, GV* namegv, SV* ckobj) {
> #define check_loop(a,b,c) check_loop(aTHX_ a,b,c)
>    PERL_UNUSED_ARG(namegv);
>    PERL_UNUSED_ARG(ckobj);
>
>    return ...;
> }
>
> to remove the entersub it's tied to?
>

Got it:

OP* remove_sub_call(OP* entersubop) {
   OP* pushop;
   OP* realop;

   pushop = cUNOPx(entersubop)->op_first;
   if (!pushop->op_sibling)
      pushop = cUNOPx(pushop)->op_first;

   realop = pushop->op_sibling;
   if (!realop || !realop->op_sibling)
      return entersubop;

   pushop->op_sibling = realop->op_sibling;
   realop->op_sibling = NULL;
   op_free(entersubop);
   return realop;
}

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About