Why callback is not called?

我是研究僧i 提交于 2019-12-22 08:22:35

问题


I have the example script from B::OPCheck module with modified PL_op_name to padsv

use B::Generate;

use B::OPCheck padsv => check => sub {
    my $op = shift;
    print "HERE";
};

my $x;
1;

But callback is not called.

When deparsing this program I can see this OP:

$perl -Ilib -Iblib/arch -MO=Terse ~/tmp/xs.pl

LISTOP (0x19828f0) leave [1] 
    OP (0x1c27ef0) enter 
    COP (0x1982938) nextstate 
    OP (0x1982998) padsv [1]           <<<< HERE IT IS
    COP (0x1c27f38) nextstate 
    OP (0x1c27f98) null [5] 

Why callback is not called?

UPD
It seems here is the answer:

For most (but not all) types of op, once the op has been initially built and populated with child ops it will be filtered through the check function referenced by the appropriate element of this array

But where to find the list of ops which will be filtered through the check function?


回答1:


I have find out next thing. I should do

wrap_op_checker(OP_PADANY, my_check, &old_checker);

Instead of:

wrap_op_checker(OP_PADSV, my_check, &old_checker);

Because OP of this type is not created. At that step it is OP_PADANY and is transformed into OP_PADSV at Perl_newSVREF which is called somewhere from Perl_yyparse+0x1834.

So because of this transformation we can not hook OP_PADSV

UPD
This behavior do not correspond to the DOC

A check routine is called when the node is fully constructed



来源:https://stackoverflow.com/questions/42455755/why-callback-is-not-called

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!