我有一个来自
B::OPCheck模块的示例脚本,修改后的PL_op_name为
padsv
use B::Generate;
use B::OPCheck padsv => check => sub {
my $op = shift;
print "HERE";
};
my $x;
1;
但是没有调用回调.
除去这个程序,我可以看到这个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]
为什么不调用回调?
UPD
看来here就是答案:
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
但是在哪里可以找到将通过检查功能过滤的操作列表?
最佳答案 我发现了下一件事.我应该做
wrap_op_checker(OP_PADANY, my_check, &old_checker);
代替:
wrap_op_checker(OP_PADSV, my_check, &old_checker);
因为没有创建此类型的OP.在该步骤,它是OP_PADANY,并在Perl_newSVREF转换为OP_PADSV,在Perl_yyparse+0x1834
之间的某处调用.
因此,由于这种转换,我们无法挂钩OP_PADSV
UPD
此行为与DOC不对应
A check routine is called when the node is fully constructed